One year later...
The introduction and monster names are done. I'm currently fighting with the end credits. As you may have guessed, the text reading routine is different from the introduction/monster one.
It's simpler. It's just:
Code: Select all
b66e: ; read a char and display it, stop if it's #$ff
lda [$20]
cmp #$ff
beq b67c
jsr b6a1 ; this is where the BAT pointer is incremented and the char added to the "display list"
jsr b687
bra b66e
b67c:
jsr b687
lda [$20]
sta <$22
jsr b687
rts
b687: ; increment text pointer
clc
lda <$20
adc #$01
sta <$20
cla
adc <$21
sta <$21
rts
Unfortunately, the text is compressed. I can't just do a
lda [$20]. I have to call the decompression routine. Hopefully space can be saved by rewriting the previous code a little bit.
Code: Select all
b66e:
lda [$20]
cmp #$ff
beq b67c
jsr b6a1
jsr b687
bra b66e
b67c:
jsr b687
lda [$20]
sta <$22
; As the increment routine follows, we can brutally the jsr/rts and save 4 bytes.
b687:
inc <$20
bne .inc_end
inc <$21
inc_end:
rts
10 bytes saved!
The next thing to do is to remove the simple loads with the decrompression routine. The thing is that the decompression routine automatically increment the text pointer. We don't need to call
b687 in the read loop.
Code: Select all
b66e:
jsr bb1a ; decompress text
cmp #$ff
beq b67c
jsr b6a1
bra b66e
b67c:
lda [$20]
; The rest is left unchanged
We removed 2
jsr but changed the
lda <zp with a
jsr. This makes a 5 bytes save.
We now have 15 bytes of free space. This will come handy because as you may have noticed, at the end of the text reading we read an extra byte and store it in
<$22.
This byte seems to be the y BAT position of the text. This means that I just can't brutally encode the text as I did for the introduction. I need to modify the script and its encoder to add this extra byte. Otherwise the whole display is foobared (and it currently is).
And by looking at the ROM, it's not just 1 extra byte but 2 bytes. One at the end of the string and another one at the beginning of the next one.
I'll have to check the
b66e caller...
Yeepee!