I don't even know how or why, but when I changed everything to where I assembly one file instead of multiple, I noticed that what I made kept crashing. (I haven't messed with anything over the whole winter break, so I'm just now noticing.) Basically, what it does is in the first millisecond, a sprite (or multiple sprites layered over each other) appears, and then move sporadically and flips and the back ground also moves and then it just stops.
In my "Object Identifier" code where it identifies an object and then jumps to its corresponding code, it first sets direct page to be the address of the beginning of the first object slot (and also stores the address in "ObjectOffset" to know what it is if direct page has been changed. Seeing this now, I might actually get rid of that, but I doubt it has anything to do with the problem)
It then looks for the identity of the first object, and seeing that in the main code I crossed out what I was uploading,
The whole object table should be zero filled, and thus the "object identifier" code should then just look at the next object, and then the next object, and then eventually it would be done. (I've verified that "start_metasprite" and "start_process_oam" aren't causing the problem, because I've deleted the jumps to them and the game still runs the same way)
I'm guessing that the object table is for some reason not filled out with zeros like it must have been earlier and that it's loading a number that is beyond what I've made in the object table and jumping somewhere crazy, (and not coming back obviously) because I put an "rts" and then later a "brk" at "next_object" (where it should be jumping, because I never even spawned an object) and neither changed it. However, I did erase the line "jsr (ObjectIdentificationTable-2,x)", and it worked like it should (no object appeared onscreen, aside for the first frame where a sprite does, but it did that even when it was working), which further roots my suspicion.
Anyway, if anyone wants to try and find the problem, here you go. I don't think it should be a difficult fix, I'm just kind of confused.
In my "Object Identifier" code where it identifies an object and then jumps to its corresponding code, it first sets direct page to be the address of the beginning of the first object slot (and also stores the address in "ObjectOffset" to know what it is if direct page has been changed. Seeing this now, I might actually get rid of that, but I doubt it has anything to do with the problem)
Code:
.proc start_object_identifier
rep #$30 ; A=16, X/Y=16
lda #ObjectTable
sta a:ObjectOffset
tcd
rep #$30 ; A=16, X/Y=16
lda #ObjectTable
sta a:ObjectOffset
tcd
It then looks for the identity of the first object, and seeing that in the main code I crossed out what I was uploading,
Code:
; rep #$30 ; A=16, X/Y=16
; lda #Object1
; sta NewObjectRequest
; jsr start_object_spawner
;
; lda #Player1MetaspriteTable
; sta ObjectTable+MetaspriteTableOffset,x
; lda #Object1
; sta NewObjectRequest
; jsr start_object_spawner
;
; lda #Player1MetaspriteTable
; sta ObjectTable+MetaspriteTableOffset,x
The whole object table should be zero filled, and thus the "object identifier" code should then just look at the next object, and then the next object, and then eventually it would be done. (I've verified that "start_metasprite" and "start_process_oam" aren't causing the problem, because I've deleted the jumps to them and the game still runs the same way)
Quote:
object_identifier_loop:
lda Identity ;load the object identification byte of the object we're currently on
beq next_object
tax ;put the result in x so we can offset the object identification table to see what the object is
jsr (ObjectIdentificationTable-2,x) ;jump to the code that corresponds with the object
rep #$30 ; A=16, X/Y=16
next_object:
lda a:ObjectOffset ;says how many objects have been identified
clc
adc #$0030 ;add 48 to look at the next object
sta a:ObjectOffset ;store the result for the next time we go through the loop
tcd ;transfer the accumulator to y for "cpy #8192" and "lda ObjectTable,y"
cmp #ObjectTableSize+ObjectTable ;sees if all objects have been identified (each object is 128 bytes)
bne object_identifier_loop ;if so, quit searching
lda #ObjectTable
tcd
jsr start_metasprite
lda #$0000
tcd
jsr start_process_oam
rts
.endproc
;====================================================================================
; ObjectIdentificationTable
;====================================================================================
ObjectIdentificationTable:
.word object1,object2
lda Identity ;load the object identification byte of the object we're currently on
beq next_object
tax ;put the result in x so we can offset the object identification table to see what the object is
jsr (ObjectIdentificationTable-2,x) ;jump to the code that corresponds with the object
rep #$30 ; A=16, X/Y=16
next_object:
lda a:ObjectOffset ;says how many objects have been identified
clc
adc #$0030 ;add 48 to look at the next object
sta a:ObjectOffset ;store the result for the next time we go through the loop
tcd ;transfer the accumulator to y for "cpy #8192" and "lda ObjectTable,y"
cmp #ObjectTableSize+ObjectTable ;sees if all objects have been identified (each object is 128 bytes)
bne object_identifier_loop ;if so, quit searching
lda #ObjectTable
tcd
jsr start_metasprite
lda #$0000
tcd
jsr start_process_oam
rts
.endproc
;====================================================================================
; ObjectIdentificationTable
;====================================================================================
ObjectIdentificationTable:
.word object1,object2
I'm guessing that the object table is for some reason not filled out with zeros like it must have been earlier and that it's loading a number that is beyond what I've made in the object table and jumping somewhere crazy, (and not coming back obviously) because I put an "rts" and then later a "brk" at "next_object" (where it should be jumping, because I never even spawned an object) and neither changed it. However, I did erase the line "jsr (ObjectIdentificationTable-2,x)", and it worked like it should (no object appeared onscreen, aside for the first frame where a sprite does, but it did that even when it was working), which further roots my suspicion.
Anyway, if anyone wants to try and find the problem, here you go. I don't think it should be a difficult fix, I'm just kind of confused.
Attachment: