Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; **************************************
- ; ***DEFINES AND BASE ROM PREPARATION***
- ; **************************************
- .MEMORYMAP
- DEFAULTSLOT 1
- SLOTSIZE $4000
- SLOT 0 $0000
- SLOT 1 $4000
- .ENDME
- .ROMBANKSIZE $4000
- .ROMBANKS 32
- .COMPUTEGBCOMPLEMENTCHECK
- .COMPUTEGBCHECKSUM
- .BACKGROUND "kaeru.gb"
- .UNBACKGROUND $1320 $13FF ; Bank $00
- .UNBACKGROUND $35A0 $37FF ; Bank $00
- .UNBACKGROUND $3C20 $3FFF ; Bank $00
- .UNBACKGROUND $7FE0 $7FFF ; Bank $01
- .UNBACKGROUND $8510 $87FF ; Bank $02
- .UNBACKGROUND $99B0 $AFFF ; Bank $02
- .UNBACKGROUND $B9D0 $BFFF ; Bank $02
- .UNBACKGROUND $E550 $F6FF ; Bank $03
- .UNBACKGROUND $13A90 $13FFF ; Bank $04
- .UNBACKGROUND $15940 $16FFF ; Bank $05
- .UNBACKGROUND $17DA0 $17FFF ; Bank $05
- .UNBACKGROUND $1B4E0 $1BFFF ; Bank $06
- .UNBACKGROUND $1F950 $1FFFF ; Bank $07
- .UNBACKGROUND $23780 $23FFF ; Bank $08
- .UNBACKGROUND $24000 $27FFF ; Bank $09 - The whole Bank is free
- .UNBACKGROUND $2BD50 $2BFFF ; Bank $0A
- .UNBACKGROUND $2FF30 $2FFFF ; Bank $0B
- .UNBACKGROUND $32270 $33FFF ; Bank $0C
- .UNBACKGROUND $37830 $37FFF ; Bank $0D
- .UNBACKGROUND $38000 $3BFFF ; Bank $0E - The whole Bank is free
- .UNBACKGROUND $3C000 $3FFFF ; Bank $0F - The whole Bank is free
- .UNBACKGROUND $43780 $43FFF ; Bank $10
- .UNBACKGROUND $44000 $47FFF ; Bank $11 - The whole Bank is free
- .UNBACKGROUND $4FA10 $4FFFF ; Bank $13
- .UNBACKGROUND $53000 $53FFF ; Bank $14
- .UNBACKGROUND $5C400 $5CFFF ; Bank $17
- .UNBACKGROUND $5EC60 $5EFFF ; Bank $17
- .UNBACKGROUND $63FC0 $63FFF ; Bank $18
- .UNBACKGROUND $67FC0 $67FFF ; Bank $19
- .UNBACKGROUND $6BFC0 $6BFFF ; Bank $1A
- .UNBACKGROUND $6C370 $6FFFF ; Bank $1B
- .UNBACKGROUND $73FF0 $73FFF ; Bank $1C
- ;.UNBACKGROUND $7F6D0 $7FFFF ; Bank $1F ; May create a conflict with the English translation
- ; Bank definitions:
- .define BANK_ROUTINES $09
- .define BANK_c1 $0E
- .define BANK_c2 $0F
- .define BANK_c3 $11
- ; Routine definitions:
- .define COPYDATA $0E82 ; Copies BC bytes from HL to DE
- .define SETOFFSETCOPYDATA $0EF8 ; Prepares the destination values at $C280-$C282 and calls COPYDATA
- .define COPYDATAWITHBUFFER $05A1; Copies $C282* bytes from $C283 to $C280*
- .define SETDATA16 $0EC3 ; Writes byte A BC times to HL
- .define SETDATA $0EBE ; Writes byte A B times to HL
- .define GETVAL $07D4 ; Loads HL (bank A) into A
- .define COPYTOMAP $0F11 ; COPY TO BGMAP, probably at V-Blank [Not enterly sure]
- .define CHANGEBANK $07A3 ; Switches ROM & RAM Bank. ROM = bits 0-4, RAM = bits 5-7
- .define GETFROMTABLE $101E ; HL=HL+A*4. Used to get an item from a 4 bytes table
- .define GETFROMTABLEPOINTER $07E5 ; Switches to bank $FFB0, gets the table offset from HL and calls GETFROMTABLE
- ; Misc.
- .define TEXTGFX $C477 ;
- .define TEXTGFXOFFSET $9600
- .define TEXTGFXOFFSET4 $97C0 ; This is where the graphics in the bubble are stored (4 bytes)
- .define TEXTGFXOFFSET1 $97B0 ; This is where the graphics in the bubble are stored (1 byte)
- .define ITEMSOFFSET $4958 ;
- .define CURRENT_BANK $FFB0 ;
- .define SHOWSPRITES_FLAG $C47B ;
- .define BUBBLE_OFFSET $C471
- .define CHAR_CURPOSITION $C47F ; Current character while reading text. Holds the text size afterwards.
- .define TEXT_BANK $C481 ;
- .define PLAYERSNAMEAUX $C3F0;$C402;$C406 ;
- .define SAVEDPLAYERSNAME $CC20 ; Original offset: $CBDF
- .define SAVEDPLAYERSNAMESIZE $CC28 ; Used to draw only as much characters as needed
- ; Flags definitions:
- .define INTFLAG $FFB5 ; If $FFB5=$01, [...]
- .define BIGTEXT_FLAG $C473
- .define AUXFLAG
- ; Hardware definitions:
- .define STAT $FF41 ; LCDC Status
- .define VBK $FF4F ; VRAM Bank
- .define SVBK $FF70 ; WRAM Bank
- .define BCPS $FF68 ; Background Palette Index (GBC)
- .define BCPD $FF69 ; Background Palette Data (GBC)
- .define OCPS $FF6A ; Sprite Palette Index (GBC)
- .define OCPD $FF6B ; Sprite Palette Data (GBC)
- ; Main Text Routine
- .BANK $03 SLOT 1
- .ORGA $568D
- .SECTION "MainTextRoutine" OVERWRITE
- ld a,$03
- ld ($C46E),a ; Sets the type of text: $03=Press to continue, $02=Closes automatically, etc.
- ; Cleans letter distribution map for BGMap:
- ld hl,$CAC2
- ld b,$00
- ld a,$FF
- call SETDATA
- ; Cleans the text mask:
- ld hl,$C482
- ld b,$24
- ld a,$FE
- call SETDATA
- ; Cleans the second line of the text mask:
- ld hl,$C4A6
- ld b,$24
- ld a,$FE
- call SETDATA
- ; Cleans this unknown area:
- ld hl,$C4CA
- ld b,$24
- xor a
- call SETDATA
- ; Initializes flags (probably)
- xor a
- ld ($C47C),a
- ld (BIGTEXT_FLAG),a
- ld ($C474),a
- ld ($C475),a
- ld ($C534),a
- ld ($C533),a
- ld ($C535),a
- ld ($C46C),a
- call MisteryRoutine ; ?
- call $5905 ; Prints text to RAM
- ld hl,BUBBLE_OFFSET
- ldi a,(hl)
- ld h,(hl)
- ld l,a
- ld de,$0021 ; +$0021 for the first text row
- add hl,de
- ld a,h
- and $FB
- ld h,a
- ld b,$12
- ld a,$B4
- call COPYTOMAP ; Cleans the first row (first text line)
- ld hl,BUBBLE_OFFSET
- ldi a,(hl)
- ld h,(hl)
- ld l,a
- ld de,$0041 ; +$0041 for the second row (in-between text lines)
- add hl,de
- ld a,h
- and $FB
- ld h,a
- ld b,$12
- ld a,$B4
- call COPYTOMAP ; Cleans the second line
- ld hl,BUBBLE_OFFSET
- ldi a,(hl)
- ld h,(hl)
- ld l,a
- ld de,$0061 ; +$0061 for the third row (second text line)
- add hl,de
- ld a,h
- and $FB
- ld h,a
- ld b,$12
- ld a,$B4
- call COPYTOMAP
- call OutputText ; Prints text into VRAM
- call GraphicsInText ; Routine to draw graphics on the bubble
- ld a,($C474)
- cp $02
- call z,$59EB ; Makes a couple of graphics blink?
- ld a,(BIGTEXT_FLAG)
- and a
- jp nz,$5A80 ; Print big text attributes to BGMap
- jp PrintRegularText ; Print regular text attributes to BGMap
- .ENDS
- .ORGA $5731
- .SECTION "MisteryRoutine" OVERWRITE
- MisteryRoutine:
- ld hl,CHAR_CURPOSITION
- ldi a,(hl)
- ld h,(hl)
- ld l,a
- ld a,(TEXT_BANK)
- call GETVAL
- inc hl
- cp $F1
- jr nc,SpecialChar
- ld e,a
- ld d,$00
- ld a,($C46C)
- and a
- jr z,label_03.111
- ld hl,$00DA
- add hl,de
- ld d,h
- ld e,l
- label_03.111:
- ld hl,$CAC2
- ld a,b
- add a
- add l
- ld l,a
- ld a,$00
- adc h
- ld h,a
- ld (hl),d
- inc hl
- ld (hl),e
- ld c,$01
- EndSpecialChar:
- ld hl,CHAR_CURPOSITION
- ld a,(hl)
- add c
- ldi (hl),a
- ld a,$00
- adc (hl)
- ld (hl),a
- ld a,b
- ld hl,$C4CA
- add l
- ld l,a
- ld a,$00
- adc h
- ld h,a
- ld a,($C47C)
- ld (hl),a
- inc b
- ld a,($C427)
- cp $08
- jr z,SavingProgress
- ld a,$23
- jr NotSavingProgress
- SavingProgress:
- ld a,$7F
- NotSavingProgress:
- cp b
- jr nc,MisteryRoutine
- ld hl,CHAR_CURPOSITION
- ldi a,(hl)
- ld h,(hl)
- ld l,a
- ld a,(TEXT_BANK)
- call GETVAL
- cp $FF
- ret nz
- ld a,$7F
- ld ($C52F),a
- ret
- SpecialChar:
- cp $FF
- jp z,$58FF
- cp $FE
- jp z,$58EB ; White space
- cp $FD
- jp z,$58CB ; Line break?
- cp $FC
- jp z,$5824
- cp $FB
- jr z,label_03.118
- cp $FA
- jp z,SpecialCharFA ; If FA80, it prints Sable's name
- cp $F9
- jp z,$5877
- cp $F8
- jp z,$588F
- cp $F7
- jp z,$58C0
- cp $F6
- jp z,$5868
- cp $F5
- jp z,$58A7
- cp $F4
- jr z,label_03.117 ; Kanji?
- cp $F3
- jr z,label_03.116
- cp $F2
- jr z,label_03.115
- cp $F1
- ld a,(TEXT_BANK)
- call GETVAL
- ld ($C47C),a
- dec b
- ld c,$02
- jp EndSpecialChar
- label_03.115:
- ld a,$01
- ld ($C47A),a
- dec b
- ld c,$01
- jp EndSpecialChar
- label_03.116:
- ld a,$00
- ld ($C46C),a
- dec b
- ld c,$01
- jp EndSpecialChar
- label_03.117:
- ld a,$01
- ld ($C46C),a
- dec b
- ld c,$01
- jp EndSpecialChar
- label_03.118:
- push bc
- ld a,(TEXT_BANK)
- call GETFROMTABLEPOINTER
- call $240A
- pop bc
- dec b
- ld c,$02
- jp EndSpecialChar
- push bc ; $1824: $c5
- ld a,($c481) ; $1825: $fa $81 $c4
- call $07d4 ; $1828: $cd $d4 $07
- call $23b6 ; $182b: $cd $b6 $23
- pop bc ; $182e: $c1
- dec b ; $182f: $05
- ld c,$02 ; $1830: $0e $02
- jp $5761 ; $1832: $c3 $61 $57
- SpecialCharFA:
- ld a,(TEXT_BANK)
- call GETVAL
- cp $80 ; If 80, Sable's name
- push bc
- call nc,$5E8b
- pop bc
- ld hl,$5F29
- call $102d ; $1845: $cd $2d $10
- ldi a,(hl) ; $1848: $2a
- ld h,(hl) ; $1849: $66
- ld l,a ; $184a: $6f
- push bc ; $184b: $c5
- ld a,b ; $184c: $78
- add a ; $184d: $87
- ld de,$cac2 ; $184e: $11 $c2 $ca
- add e ; $1851: $83
- ld e,a ; $1852: $5f
- ld a,$00 ; $1853: $3e $00
- adc d ; $1855: $8a
- ld d,a ; $1856: $57
- ldi a,(hl) ; $1857: $2a
- push af ; $1858: $f5
- add a ; $1859: $87
- ld b,a ; $185a: $47
- call COPYDATA
- pop af ; $185e: $f1
- dec a ; $185f: $3d
- pop bc ; $1860: $c1
- add b ; $1861: $80
- ld b,a ; $1862: $47
- ld c,$02 ; $1863: $0e $02
- jp $5761 ; $1865: $c3 $61 $57
- ld a,(TEXT_BANK) ; $1868: $fa $81 $c4
- call GETVAL
- ld ($c477),a ; $186e: $ea $77 $c4
- dec b ; $1871: $05
- ld c,$02 ; $1872: $0e $02
- jp $5761 ; $1874: $c3 $61 $57
- .ENDS
- .ORGA $5E94
- .SECTION "PlayersName" OVERWRITE
- PlayersName:
- ld hl,PLAYERSNAMEAUX
- ld b,$08
- xor a
- call SETDATA
- call CopyPlayersName
- ;ld a,$06 ; Characters to be printed
- ld a,(SAVEDPLAYERSNAMESIZE)
- ;inc a
- ld ($C536),a
- ld hl,PLAYERSNAMEAUX
- ld de,$C537
- ld b,$16
- call COPYDATA
- jr PlayersNameEnd
- ShowCoinsCount:
- ld a,($CBDB)
- ldh ($8C),a
- ld a,($CBDC)
- ldh ($8B),a
- ld a,($CBDD)
- ldh ($8A),a
- jr label_03.166
- ld a,($D105)
- ldh ($8C),a
- ld a,($D106)
- ldh ($8B),a
- ld a,($D107)
- ldh ($8A),a
- label_03.166:
- call $1F5A
- xor a
- ld b,a
- ld c,a
- label_03.167:
- ld hl,$C41C
- add l
- ld l,a
- ld a,$00
- adc h
- ld h,a
- ld a,(hl)
- cp $B7
- jr z,label_03.168
- add $40
- push af
- ld a,c
- ld hl,$C537
- call $102D
- pop af
- ld (hl),$00
- inc hl
- ld (hl),a
- inc c
- label_03.168:
- inc b
- ld a,b
- cp $07
- jr nz,label_03.167
- ld a,c
- ld ($C536),a
- PlayersNameEnd:
- xor a
- ret
- .ENDS
- .SECTION "CopyPlayersName" FREE
- CopyPlayersName:
- ld de,SAVEDPLAYERSNAME
- ld hl,PLAYERSNAMEAUX
- ld a,(de)
- call PlayersNameChar
- ld a,(de)
- call PlayersNameChar
- ld a,(de)
- call PlayersNameChar
- ld a,(de)
- call PlayersNameChar
- ld a,(de)
- call PlayersNameChar
- ld a,(de)
- PlayersNameChar:
- inc de
- cp $FF
- jr nz,PlayersNameKeepGoing
- ld a,$FF
- ldi (hl),a
- ldi (hl),a
- ret
- PlayersNameKeepGoing:
- add $50
- ld (hl),$00
- inc hl
- ld (hl),a
- inc hl
- ret
- .ENDS
- .ORGA $597E
- .SECTION "OutputText" OVERWRITE
- OutputText:
- ld a,(BIGTEXT_FLAG)
- and a
- jr z,RegularText
- ld d,$08
- LoopBigText:
- push de
- ld hl,$C4EE
- ld a,d
- dec a
- call $102D
- ldi a,(hl)
- ld c,(hl)
- ld b,a
- and c
- cp $FF
- jr z,BigTextEnded
- ld hl,$5800
- call $1073
- add hl,bc
- push hl
- ld hl,TEXTGFXOFFSET
- ld c,d
- ld b,$00
- dec c
- call $1073
- add hl,bc
- ld d,h
- ld e,l
- pop hl
- ld b,$40
- ld a,$14
- call COPYDATA_A
- BigTextEnded:
- pop de
- dec d
- jr nz,LoopBigText
- ret
- RegularText:
- ld d,$20
- LoopRegularText:
- push de
- ld hl,$C4EE
- ld a,d
- dec a
- call $102D
- ldi a,(hl)
- ld c,(hl)
- ld b,a
- and c
- cp $FF
- jr z,RegularTextEnded
- ld hl,$4000
- call $107B
- add hl,bc
- push hl
- ld hl,TEXTGFXOFFSET
- ld a,d
- dec a
- call $0FFC
- ld d,h
- ld e,l
- pop hl
- ld b,$10
- ld a,$14
- call COPYDATA_A
- RegularTextEnded:
- pop de
- dec d
- jr nz,LoopRegularText
- ret
- .ENDS
- .ORGA $59F9
- .SECTION "PrintRegularText" OVERWRITE
- PrintRegularText:
- ld hl,BUBBLE_OFFSET
- ldi a,(hl)
- ld h,(hl)
- ld l,a
- ld de,$0021 ; First line text
- add hl,de
- ld a,h
- and $FB
- ld d,a
- ld e,l
- ld b,$12
- ld c,$00
- call label_5A22
- ld hl,BUBBLE_OFFSET
- ldi a,(hl)
- ld h,(hl)
- ld l,a
- ld de,$0061 ; Second line text
- add hl,de
- ld a,h
- and $FB
- ld d,a
- ld e,l
- ld b,$12
- ld c,$12
- label_5A22:
- call $5B1E
- ld a,d
- ld ($C280),a ; Text VRAM offset
- ld a,e
- ld ($C281),a
- ld a,$01
- ld ($C282),a
- ld a,c
- ld hl,$CAC2 ; Letter distribution for BGMap
- add l
- ld l,a
- ld a,$00
- adc h
- ld h,a
- ld a,(hl)
- add $60
- cp $B4 ; If blankspace
- jr nz,RegChar
- call $5B0F
- jr c,BlankspaceNext
- xor a
- ld ($C3AB),a
- jr BlankspaceNext
- RegChar:
- ld ($C283),a
- push bc
- push hl
- push de
- ld a,$01
- ldh (<INTFLAG),a
- call $021F ; Trigger for all copy data events?
- ld a,($C47A)
- and a
- call nz,$2D54
- pop de
- pop hl
- pop bc
- BlankspaceNext:
- push bc
- push de
- push hl
- ld hl,$C4CA
- ld a,c
- add l
- ld l,a
- ld a,$00
- adc h
- ld h,a
- ld a,(hl)
- and a
- call nz,$02D8
- pop hl
- pop de
- pop bc
- inc de
- inc c
- dec b
- jr nz,label_5A22
- ret
- .ENDS
- ; Display graphics in text
- .BANK $03 SLOT 1
- .ORGA $5E10
- .SECTION "GraphicsInText" OVERWRITE
- GraphicsInText:
- ld a,(TEXTGFX)
- cp $FF ; If TEXTGFX=$FF, no item is shown
- ret z
- cp $28
- jr nc,TextGFX4x4 ;
- cp $24
- jr nc,TextGFX1x1
- TextGFX4x4:
- ld hl,ITEMSOFFSET
- call GETFROMTABLE
- ld a,$06
- call GETFROMTABLEPOINTER
- ld de,TEXTGFXOFFSET4
- ld b,$40
- ld a,$12
- call COPYDATA_A ; Print graphics
- ld a,$22
- ld ($C200),a
- ld hl,$C201
- ld a,$7C
- LoopTextGFX4x4:
- ldi (hl),a
- inc a
- cp $80
- jr nz,LoopTextGFX4x4
- TextGFXFinished:
- ld hl,BUBBLE_OFFSET
- ldi a,(hl)
- ld h,(hl)
- ld l,a
- ld de,$0022
- add hl,de
- ld a,h
- and $FB
- ld b,a
- ld c,l
- jp InputNameBuffer
- TextGFX1x1:
- push af
- ld hl,ITEMSOFFSET
- call GETFROMTABLE
- ld a,$06
- call GETFROMTABLEPOINTER
- ld de,TEXTGFXOFFSET1
- ld b,$50
- ld a,$12
- call COPYDATA_A
- ld a,$21
- ld ($C200),a
- pop af
- sub $24
- ld hl,$5E87
- add l
- ld l,a
- ld a,$00
- adc h
- ld h,a
- ld a,(hl)
- ld ($C201),a
- ld a,$7F
- ld ($C202),a
- jr TextGFXFinished
- .ENDS
- ; It switches to Bank A, sets $C280-2, copies BC bytes from HL to DE and switches back to the original Bank
- .BANK 0 SLOT 0
- .ORG $0FC0
- .SECTION "COPYDATA_A" OVERWRITE
- COPYDATA_A:
- push bc
- ld b,a ;
- ldh a,(<CURRENT_BANK) ;
- ld c,a ;
- ld a,b ; c=CURRENT_BANK
- call CHANGEBANK
- ld a,c
- pop bc
- push af
- call SETOFFSETCOPYDATA
- pop af
- jp CHANGEBANK ; Goes back to the original Bank
- ;0FD3:
- push bc
- ld b,a
- ldh a,(<CURRENT_BANK)
- ld c,a
- ld a,b
- call CHANGEBANK
- ld a,c
- pop bc
- push af
- call COPYDATA_C280
- pop af
- jp CHANGEBANK
- .ENDS
- .BANK 0 SLOT 0
- .ORG $0F2C
- .SECTION "COPYDATA_C280" OVERWRITE
- COPYDATA_C280:
- push de
- push hl
- ld l,$40
- ld a,c
- sub $40
- ld c,a
- ld a,b
- sbc $00
- ld b,a ; BC=BC-$0040
- jr nc,COPYDATA_C280_Regular
- ld a,c
- add $40
- ld l,a
- ld bc,$0000
- COPYDATA_C280_Regular:
- push bc
- ld bc,$C280
- ld a,d
- ld (bc),a
- inc bc
- ld a,e
- ld (bc),a
- inc bc
- ld a,l
- ld (bc),a
- inc bc
- ld d,b
- ld e,c
- pop bc
- pop hl
- push hl
- push bc
- ld b,$40
- call COPYDATA
- ld a,$01
- ldh (<INTFLAG),a ; This triggers a copy data event at $C280
- call $021F ; Trigger for all copy data events?
- pop bc
- pop hl
- pop de
- ld a,e
- add $40
- ld e,a
- ld a,d
- adc $00
- ld d,a
- ld a,l
- add $40
- ld l,a
- ld a,h
- adc $00
- ld h,a
- ld a,b
- or c
- jr nz,COPYDATA_C280
- ret
- .ENDS
- ; Input Sablé's name cursor position fix
- .BANK $02 SLOT 1
- .ORGA $74D8
- .SECTION "InputNameCursor" OVERWRITE
- ;add $1C
- add $4C
- .ENDS
- ; Input Sablé's name
- .BANK $02 SLOT 1
- .ORGA $759B
- .SECTION "InputNameHook" OVERWRITE
- jp label_02.171
- .ENDS
- ; Draw Input Sablé's name screen
- .BANK $02 SLOT 1
- .ORGA $75D6
- .SECTION "DrawInputNameHook" OVERWRITE
- call InitMemory
- jp label_75D6
- .ENDS
- .SECTION "InputName" FREE
- label_02.171:
- cp $FF
- jr nz,NotFinished
- ld a,(SAVEDPLAYERSNAMESIZE)
- cp $00
- ret z
- dec a
- ld (SAVEDPLAYERSNAMESIZE),a
- ld a,$06
- ld ($FF8D),a
- NotFinished:
- ld a,$28
- ld ($C3AB),a
- ld hl,$77D7
- ldh a,($8E)
- add l
- ld l,a
- ld a,$00
- adc h
- ld h,a
- ld b,(hl)
- ldh a,($8D)
- ld hl,SAVEDPLAYERSNAME
- add l
- ld l,a
- ld a,$00
- adc h
- ld h,a
- ld (hl),b
- ld hl,$FF8D
- inc (hl)
- ld a,(hl)
- ;cp $04 ; 4 characters
- cp $06
- jp nz,label_75D6
- dec (hl)
- jp label_75D6
- label_02.172:
- ld hl,$FF8D
- dec (hl)
- ld a,(hl)
- cp $FF
- ret nz
- ld (hl),$00
- call $0286
- jp $0798
- label_75D6:
- ld a,$16 ; ld a,$14. Low nibble is how much characters would be drawn
- ld ($C200),a
- ld a,(SAVEDPLAYERSNAME)
- call label_7605
- ld ($C201),a
- ld a,(SAVEDPLAYERSNAME+1)
- call label_7605
- ld ($C202),a
- ld a,(SAVEDPLAYERSNAME+2)
- call label_7605
- ld ($C203),a
- ld a,(SAVEDPLAYERSNAME+3)
- call label_7605
- ld ($C204),a
- ld a,(SAVEDPLAYERSNAME+4)
- call label_7605
- ld ($C205),a
- ld a,(SAVEDPLAYERSNAME+5)
- call label_7605
- ld ($C206),a
- ld bc,$986A ; Screen position: ld bc,$9866
- jp InputNameBuffer
- label_7605:
- cp $FF
- jr nz,NotNullChar
- ld a,$DF
- ret
- NotNullChar:
- add $20
- ret
- InitMemory:
- ld a,$5F
- push hl
- ld hl,SAVEDPLAYERSNAME
- ldi (hl),a
- ldi (hl),a
- ldi (hl),a
- ldi (hl),a
- ldi (hl),a
- ldi (hl),a
- ldi (hl),a
- pop hl
- ret
- .ENDS
- ; Sablé's name transfer from buffer
- .BANK 0 SLOT 0
- .ORG $0537
- .SECTION "InputNameBuffer" OVERWRITE
- InputNameBuffer:
- ld l,$00
- ld h,$C2
- ld a,c
- ldh ($8A),a
- ld a,b
- ldh ($8B),a
- ld a,(hl)
- and $0F
- ldh ($8C),a
- ldi a,(hl)
- srl a
- srl a
- srl a
- srl a
- ld b,a
- label_00.040:
- xor a
- ldh ($B4),a
- ld de,$C180
- ld a,(de)
- inc de
- add e
- ld e,a
- ld a,d
- adc $00
- ld d,a
- label_00.041:
- ldh a,($8B)
- ld (de),a
- inc de
- ldh a,($8A)
- ld (de),a
- inc de
- ldh a,($8C)
- ld c,a
- ld (de),a
- inc de
- label_00.042:
- ldi a,(hl)
- ld (de),a
- inc de
- dec c
- jr nz,label_00.042
- push bc
- ldh a,($8A)
- add $20
- ldh ($8A),a
- ldh a,($8B)
- ld b,a
- adc $00
- ldh ($8B),a
- xor b
- and $04
- jr z,label_00.043
- ldh a,($8B)
- xor $04
- ldh ($8B),a
- label_00.043:
- pop bc
- dec b
- jr nz,label_00.041
- xor a
- ld (de),a
- dec de
- ld a,e
- sub $80
- ld de,$C180
- ld (de),a
- ld a,$01
- ldh ($B4),a
- ret
- .ENDS
- ; Clean underscores
- .BANK $02 SLOT 1
- .ORGA $7555
- .SECTION "CleanUnderscoresHook" OVERWRITE
- jp CleanUnderscores
- .ENDS
- .SECTION "CleanUnderscores" FREE
- CleanUnderscores:
- ld a,$24
- ld ($C3AB),a
- ld hl,SAVEDPLAYERSNAME
- ldi a,(hl)
- cp $5F
- jr nz,label_02.170
- ldi a,(hl)
- cp $5F
- jr nz,label_02.170
- ldi a,(hl)
- cp $5F
- jr nz,label_02.170
- ldi a,(hl)
- cp $5F
- jr nz,label_02.170
- ldi a,(hl)
- cp $5F
- jr nz,label_02.170
- ldi a,(hl)
- cp $5F
- ret z
- label_02.170:
- ld hl,SAVEDPLAYERSNAME
- ld a,(hl)
- call label_7595
- ldi (hl),a
- ld a,(hl)
- call label_7595
- ldi (hl),a
- ld a,(hl)
- call label_7595
- ldi (hl),a
- ld a,(hl)
- call label_7595
- ldi (hl),a
- ld a,(hl)
- call label_7595
- ldi (hl),a
- ld a,(hl)
- call label_7595
- ldi (hl),a
- ld a,(hl)
- call label_7595
- ld a,$01
- ldh ($C8),a
- ld a,$00
- ld ($C427),a
- xor a
- ld ($C45C),a
- ret
- label_7595:
- cp $5F
- ret nz
- ; Perfect opportunity to set the name size:
- ld a,(SAVEDPLAYERSNAMESIZE)
- cp 0
- jr nz,NameSizeSet
- ld a,l
- sub $20
- ld (SAVEDPLAYERSNAMESIZE),a
- NameSizeSet:
- ld a,$FF
- ret
- .ENDS
- ; Input name screen tiles
- .BANK $13 SLOT 1
- .ORGA $755F
- .SECTION "InputTiles" OVERWRITE
- .db $2F,$4F,$46,$4B,$40,$42 ; "Prince"
- .db $DF,$DF,$DF ; " "
- .ENDS
- ; SAVEDPLAYERSNAME read fixes
- .BANK $03 SLOT 1
- .ORGA $5F04
- .SECTION "SAVEDPLAYERSNAMEf2Hook" SIZE $1D OVERWRITE
- jp SAVEDPLAYERSNAMEf2
- jp SAVEDPLAYERSNAMEf2b
- .ENDS
- .SECTION "SAVEDPLAYERSNAMEf2" FREE
- SAVEDPLAYERSNAMEf2:
- ld de,SAVEDPLAYERSNAME
- SAVEDPLAYERSNAMEf2b:
- ld hl,PLAYERSNAMEAUX
- .REPEAT 5
- ld a,(de)
- call Label_5F17
- .ENDR
- ld a,(de)
- Label_5F17:
- inc de
- cp $FF
- jp nz,$5F21
- ld a,$FF
- ldi (hl),a
- ldi (hl),a
- ret
- .ENDS
- ; Expands Diary title box
- .BANK $13 SLOT 1
- .ORGA $7688
- .SECTION "ExpandDiary1" OVERWRITE
- .db $E9,$EA,$EB,$EC,$E9,$EA,$EB,$EC,$E9,$EA,$EB,$EC,$E9,$EA,$EB,$EC,$E9,$EA,$EB,$EC,$E0,$E1,$E6,$E6,$E6,$E6,$E6,$E6,$E6,$E6,$E6,$E6,$E6,$E6,$E6,$E6,$E6,$E6,$E2,$E0,$E0,$E7,$00,$01,$02,$03,$04,$05,$06,$07,$08,$09,$0A,$0B,$0C,$0D,$0E,$0F,$E8,$E0,$E0,$E3,$E5,$E5,$E5,$E5,$E5,$E5,$E5,$E5,$E5,$E5,$E5,$E5,$E5,$E5,$E5,$E5,$E4,$E0
- .ENDS
- .BANK $03 SLOT 1
- .ORGA $6208
- .SECTION "ExpandDiaryText1" OVERWRITE
- .db $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$00,$53,$00,$76,$00,$6E,$00,$7F,$00,$86,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
- .ENDS
- .BANK $13 SLOT 1
- .ORGA $7714
- .SECTION "ExpandDiary2" OVERWRITE
- .db $C6,$C4,$10,$11,$12,$13,$14,$15,$16,$C5,$D0,$2C,$2D,$2E,$2F,$30,$31,$32,$D1,$D5,$C6,$C4,$DF,$DF,$DF,$DF,$DF,$DF,$DF,$C5,$D0,$33,$34,$35,$36,$37,$38,$39,$D1,$D5,$C6,$C4,$17,$18,$19,$1A,$1B,$1C,$1D,$C5,$D0,$DF,$DF,$DF,$DF,$DF,$DF,$DF,$D1,$D5,$C6,$C4,$DF,$DF,$DF,$DF,$DF,$DF,$DF,$C5,$D0,$3A,$3B,$3C,$3D,$3E,$3F,$40,$D1,$D5,$C6,$C4,$1E,$1F,$20,$21,$22,$23,$24,$C5,$D0,$41,$42,$43,$44,$45,$46,$47,$D1,$D5,$C6,$C4,$DF,$DF,$DF,$DF,$DF,$DF,$DF,$C5,$D0,$DF,$DF,$DF,$DF,$DF,$DF,$DF,$D1,$D5,$C6,$C4,$25,$26,$27,$28,$29,$2A,$2B,$C5,$D0,$48,$49,$4A,$4B,$4C,$4D,$4E,$D1,$D5,$C6,$C4,$DF,$DF,$DF,$DF,$DF,$DF,$DF,$C5,$D0,$DF,$DF,$DF,$DF,$DF,$DF,$DF,$D1,$D5
- .ENDS
- ; Fix Diary's name load
- .BANK $03 SLOT 1
- .ORGA $4975
- .SECTION "DiarySlot1" OVERWRITE
- ld de,$A05E
- call $5F07
- ld hl,PLAYERSNAMEAUX
- ld de,$2D32 ;ld de,$2B30
- .ENDS
- .ORGA $4992
- .SECTION "DiarySlot2" OVERWRITE
- ld de,$B05E
- call $5F07
- ld hl,PLAYERSNAMEAUX
- ld de,$3B40 ;ld de,$393E
- .ENDS
- ; Fix expanded Diary title
- .ORGA $43EC
- .SECTION "DiaryTitle1" OVERWRITE
- ld hl,$6208
- ld de,$0010
- call $25F8
- ld hl,$6240
- ld de,$1029
- call $25F8
- ld hl,$63AC
- ld de,$484E
- .ENDS
- ; Slot placeholder
- .ORGA $495C
- .SECTION "DiarySlot0" OVERWRITE
- ld de,$2C47
- .ENDS
- .ORGA $4612
- .SECTION "WriteDiary" OVERWRITE
- ld hl,$6220
- ld de,$000F
- call $25F8
- ld hl,$62B0
- ld de,$102B
- call $25F8
- ld hl,$63C8
- ld de,$2C47
- call $25F8
- ld hl,$63BA
- ld de,$484E
- call $25F8
- call $5F04
- ld hl,PLAYERSNAMEAUX
- ld de,$0106
- call $25F8 ; Write Comal's name
- .ENDS
- .ORGA $46C9
- .SECTION "WriteDiary2" OVERWRITE
- ld hl,$633C
- ld de,$102B
- .ENDS
- .ORGA $4787
- .SECTION "WriteDiary3" OVERWRITE
- ld hl,$6374
- ld de,$102B
- call $25F8
- ld hl,$6400
- ld de,$2C47
- call $25F8
- .ENDS
- .ORGA $469E
- .SECTION "WriteDiary4" OVERWRITE
- ld hl,$6304
- ld de,$102B
- call $25F8
- .ENDS
- .ORGA $4C76
- .SECTION "WriteDiary5" OVERWRITE
- ld hl,$62BE
- ld de,$2C4E
- call $25F8
- .ENDS
- .ORGA $4C8D
- .SECTION "WriteDiary5b" OVERWRITE
- ld d,$2E
- .ENDS
- .ORGA $471C
- .SECTION "WriteDiary6" OVERWRITE
- ld hl,$62B0
- ld de,$102B
- call $25F8
- ld hl,$63C8
- ld de,$2C47
- call $25F8
- ld hl,$63BA
- ld de,$484E
- call $25F8
- .ENDS
- .ORGA $484A
- .SECTION "WriteDiary7" OVERWRITE
- ld hl,$62B0
- ld de,$102B
- call $25F8
- ld hl,$63C8
- ld de,$2C47
- call $25F8
- ld hl,$63BA
- ld de,$484E
- call $25F8
- .ENDS
- .ORGA $48ED
- .SECTION "WriteDiary8" OVERWRITE
- ld hl,$6220
- ld de,$000F
- call $25F8
- call $5F04
- ld hl,PLAYERSNAMEAUX
- ld de,$0106
- call $25F8 ; Write Prince's name
- ld hl,$6304
- ld de,$102B
- call $25F8
- .ENDS
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement