ref: 880fb511e19eb6aa413af1519731074c7ec8d852
parent: e3c686f6df866d1b393d9cc9e61a750a454b5270
author: Remy Oukaour <remy.oukaour@gmail.com>
date: Sat Dec 9 10:28:03 EST 2017
More WRAM organization
--- a/engine/pokedex.asm
+++ b/engine/pokedex.asm
@@ -117,7 +117,7 @@
ret
Pokedex_InitCursorPosition: ; 400b4
- ld hl, wPokedexDataStart
+ ld hl, wPokedexOrder
ld a, [wLastDexEntry]
and a
jr z, .done
@@ -1479,11 +1479,11 @@
ld a, " "
call Pokedex_FillBox
-; Load de with wPokedexDataStart + [wDexListingScrollOffset]
+; Load de with wPokedexOrder + [wDexListingScrollOffset]
ld a, [wDexListingScrollOffset]
ld e, a
ld d, $0
- ld hl, wPokedexDataStart
+ ld hl, wPokedexOrder
add hl, de
ld e, l
ld d, h
@@ -1583,7 +1583,7 @@
add [hl]
ld e, a
ld d, $0
- ld hl, wPokedexDataStart
+ ld hl, wPokedexOrder
add hl, de
ld a, [hl]
ld [wd265], a
@@ -1614,8 +1614,8 @@
Pokedex_OrderMonsByMode: ; 40bdc
- ld hl, wPokedexDataStart
- ld bc, wPokedexMetadata - wPokedexDataStart
+ ld hl, wPokedexOrder
+ ld bc, wPokedexOrderEnd - wPokedexOrder
xor a
call ByteFill
ld a, [wCurrentDexMode]
@@ -1632,7 +1632,7 @@
.NewMode: ; 40bf6 (10:4bf6)
ld de, NewPokedexOrder
- ld hl, wPokedexDataStart
+ ld hl, wPokedexOrder
ld c, NUM_POKEMON
.loopnew
ld a, [de]
@@ -1644,7 +1644,7 @@
ret
.OldMode: ; 40c08 (10:4c08)
- ld hl, wPokedexDataStart
+ ld hl, wPokedexOrder
ld a, $1
ld c, NUM_POKEMON
.loopold
@@ -1656,7 +1656,7 @@
ret
.FindLastSeen: ; 40c18 (10:4c18)
- ld hl, wPokedexDataStart + NUM_POKEMON - 1
+ ld hl, wPokedexOrder + NUM_POKEMON - 1
ld d, NUM_POKEMON
ld e, d
.loopfindend
@@ -1675,7 +1675,7 @@
Pokedex_ABCMode: ; 40c30
xor a
ld [wDexListingEnd], a
- ld hl, wPokedexDataStart
+ ld hl, wPokedexOrder
ld de, AlphabeticalPokedexOrder
ld c, NUM_POKEMON
.loop1abc
@@ -1915,8 +1915,8 @@
add hl, de
ld a, [hl]
ld [wDexConvertedMonType], a
- ld hl, wPokedexDataStart
- ld de, wPokedexDataStart
+ ld hl, wPokedexOrder
+ ld de, wPokedexOrder
ld c, NUM_POKEMON
xor a
ld [wDexSearchResultCount], a
--- a/engine/printer/serial.asm
+++ b/engine/printer/serial.asm
@@ -292,13 +292,13 @@
Printer_CopyPacket: ; 841e2 (21:41e2)
ld a, [hli]
- ld [wca82], a
+ ld [wPrinterData], a
ld a, [hli]
- ld [wca83], a
+ ld [wPrinterData + 1], a
ld a, [hli]
- ld [wca84], a
+ ld [wPrinterData + 2], a
ld a, [hli]
- ld [wca85], a
+ ld [wPrinterData + 3], a
ld a, [hli]
ld [wPrinterChecksum], a
ld a, [hl]
@@ -307,7 +307,7 @@
Printer_ResetData: ; 841fb (21:41fb)
xor a
- ld hl, wca82
+ ld hl, wPrinterData
ld [hli], a
ld [hli], a
ld [hli], a
@@ -326,7 +326,7 @@
Printer_ComputeChecksum: ; 84219 (21:4219)
ld hl, 0
ld bc, 4
- ld de, wca82
+ ld de, wPrinterData
call .ComputeChecksum
ld a, [wPrinterSendByteCounter]
ld c, a
@@ -476,10 +476,10 @@
dw Printer_DoNothing ; 00
dw Printer_Send0x33 ; 01
- dw Printer_Sendwca82 ; 02
- dw Printer_Sendwca83 ; 03
- dw Printer_Sendwca84 ; 04
- dw Printer_Sendwca85 ; 05
+ dw Printer_SendPrinterData1 ; 02
+ dw Printer_SendPrinterData2 ; 03
+ dw Printer_SendPrinterData3 ; 04
+ dw Printer_SendPrinterData4 ; 05
dw Printer_SendNextByte ; 06
dw Printer_SendwPrinterChecksumLo ; 07
dw Printer_SendwPrinterChecksumHi ; 08
@@ -524,26 +524,26 @@
call Printer_NextInstruction
ret
-Printer_Sendwca82: ; 84339 (21:4339)
- ld a, [wca82]
+Printer_SendPrinterData1: ; 84339 (21:4339)
+ ld a, [wPrinterData]
call Printer_SerialSend
call Printer_NextInstruction
ret
-Printer_Sendwca83: ; 84343 (21:4343)
- ld a, [wca83]
+Printer_SendPrinterData2: ; 84343 (21:4343)
+ ld a, [wPrinterData + 1]
call Printer_SerialSend
call Printer_NextInstruction
ret
-Printer_Sendwca84: ; 8434d (21:434d)
- ld a, [wca84]
+Printer_SendPrinterData3: ; 8434d (21:434d)
+ ld a, [wPrinterData + 2]
call Printer_SerialSend
call Printer_NextInstruction
ret
-Printer_Sendwca85: ; 84357 (21:4357)
- ld a, [wca85]
+Printer_SendPrinterData4: ; 84357 (21:4357)
+ ld a, [wPrinterData + 3]
call Printer_SerialSend
call Printer_NextInstruction
ret
--- a/wram.asm
+++ b/wram.asm
@@ -142,9 +142,13 @@
wMonStatusFlags:: db
wGameLogicPaused:: db ; c2cd
wSpriteUpdatesEnabled:: db
-wc2cf:: db
+
+wc2cf:: db ; ????
+
wMapTimeOfDay:: db
+
ds 3
+
wPrinterConnectionOpen:: db
wPrinterOpcode:: db
wLastDexEntry:: db
@@ -324,8 +328,8 @@
SECTION "Battle", WRAM0
-UNION
-; unidentified mobile/debug
+UNION ; c608
+; unidentified uses
wc608::
NEXTU ; c608
@@ -534,6 +538,7 @@
PlayerSAtkLevel:: db ; c6cf
UNION ; c6d0
+; finish battle RAM
PlayerSDefLevel:: db ; c6d0
PlayerAccLevel:: db ; c6d1
PlayerEvaLevel:: db ; c6d2
@@ -787,16 +792,14 @@
NEXTU ; c6d0
; unown puzzle
wUnownPuzzle::
-wPuzzlePieces::
- ds 6 * 6
+wPuzzlePieces:: ds 6 * 6
wUnownPuzzleEnd::
NEXTU ; c6d0
; pokedex
wPokedexDataStart::
-wPokedexOrder:: ds NUM_POKEMON +- 1
+wPokedexOrder:: ds $100 ; NUM_POKEMON + 5
wPokedexOrderEnd::
- ds 6
wPokedexMetadata::
wDexListingScrollOffset:: db ; offset of the first displayed entry from the start
wDexListingCursor:: db ; Dex cursor
@@ -820,7 +823,7 @@
wBackupDexListingPage:: db
wDexCurrentLocation:: db
IF DEF(CRYSTAL11)
-wPokedexStatus:: ds 1
+wPokedexStatus:: db
wPokedexDataEnd::
ELSE
wPokedexDataEnd:: ds 1
@@ -849,8 +852,7 @@
SECTION "Overworld Map", WRAM0
UNION ; c800
-OverworldMap:: ; c800
- ds 1300
+OverworldMap:: ds 1300 ; c800
OverworldMapEnd::
NEXTU ; c800
@@ -863,14 +865,11 @@
; GB Printer data
wGameboyPrinter2bppSource:: ds 40 tiles
wGameboyPrinter2bppSourceEnd::
-wca80:: ds 1
+wca80:: db
wPrinterRowIndex:: db
; Printer data header
-wca82:: ds 1
-wca83:: ds 1
-wca84:: ds 1
-wca85:: ds 1
+wPrinterData:: ds 4
wPrinterChecksum:: dw ; ca86
wPrinterHandshake:: db
wPrinterStatusFlags::