[go: up one dir, main page]

Menu

[r132]: / psrp / tech4.txt  Maximize  Restore  History

Download this file

46 lines (30 with data), 2.9 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
4. Making more room: Script pointers
First we'd like to do some space management.
; A = index #
; $49D1 = 2-byte PC table
[0049B2] 49b2 11 D1 49 LD DE,49D1h AF=031B BC=0008 DE=C9C2 HL=49A6 SP=CAFC IX=C880 IY=C800 V P0=00000 P1=04000 P2=0C000 [ROM]
[0049B5] 49b5 CD C9 49 CALL 49C9h AF=031B BC=0008 DE=49D1 HL=49A6 SP=CAFC IX=C880 IY=C800 V P0=00000 P1=04000 P2=0C000 [ROM]
[0049C9] 49c9 6F LD L,A AF=031B BC=0008 DE=49D1 HL=49A6 SP=CAFA IX=C880 IY=C800 V P0=00000 P1=04000 P2=0C000 [ROM]
[0049CA] 49ca 26 00 LD H,00h AF=031B BC=0008 DE=49D1 HL=4903 SP=CAFA IX=C880 IY=C800 V P0=00000 P1=04000 P2=0C000 [ROM]
[0049CC] 49cc 29 ADD HL,HL AF=031B BC=0008 DE=49D1 HL=0003 SP=CAFA IX=C880 IY=C800 V P0=00000 P1=04000 P2=0C000 [ROM]
[0049CD] 49cd 19 ADD HL,DE AF=0300 BC=0008 DE=49D1 HL=0006 SP=CAFA IX=C880 IY=C800 V P0=00000 P1=04000 P2=0C000 [ROM]
[0049CE] 49ce 7E LD A,(HL) AF=0300 BC=0008 DE=49D1 HL=49D7 SP=CAFA IX=C880 IY=C800 V P0=00000 P1=04000 P2=0C000 [ROM]
[0049CF] 49cf 23 INC HL AF=8200 BC=0008 DE=49D1 HL=49D7 SP=CAFA IX=C880 IY=C800 V P0=00000 P1=04000 P2=0C000 [ROM]
[0049D0] 49d0 66 LD H,(HL) AF=8200 BC=0008 DE=49D1 HL=49D8 SP=CAFA IX=C880 IY=C800 V P0=00000 P1=04000 P2=0C000 [ROM]
[0049D1] 49d1 6F LD L,A AF=8200 BC=0008 DE=49D1 HL=4BD8 SP=CAFA IX=C880 IY=C800 V P0=00000 P1=04000 P2=0C000 [ROM]
[0049D2] 49d2 E9 LD PC,HL AF=8200 BC=0008 DE=49D1 HL=4B82 SP=CAFA IX=C880 IY=C800 V P0=00000 P1=04000 P2=0C000 [ROM]
; -------------------------------------------------------------------
; ~193 instances found, but scattered. Not contiguous.
; Relative pointer.
[004B82] 4b82 21 12 00 LD HL,0012h AF=8200 BC=0008 DE=49D1 HL=4B82 SP=CAFA IX=C880 IY=C800 V P0=00000 P1=04000 P2=0C000 [ROM]
[004B85] 4b85 C3 BA 59 JP 59BAh AF=8200 BC=0008 DE=49D1 HL=0012 SP=CAFA IX=C880 IY=C800 V P0=00000 P1=04000 P2=0C000 [ROM]
; -------------------------------------------------------------------
; Pointer table lookup ($0E bytes)
[0059BA] 59ba 3E 02 LD A,02h AF=8200 BC=0008 DE=49D1 HL=0012 SP=CAFA IX=C880 IY=C800 V P0=00000 P1=04000 P2=0C000 [ROM]
[0059BC] 59bc 32 FF FF LD (FFFFh),A AF=0200 BC=0008 DE=49D1 HL=0012 SP=CAFA IX=C880 IY=C800 V P0=00000 P1=04000 P2=0C000 [ROM]
...
[0059C7] 59c7 C3 3A 33 JP 333Ah AF=BE00 BC=0008 DE=80B0 HL=84BE SP=CAFA IX=C880 IY=C800 V P0=00000 P1=04000 P2=08000 [ROM]
; _____________________________________________________________________
We have 2 text banks. One uses relative pointers and the other hard-coded.
$80B2-835B is the 2-byte pointer table ($2AA size) for $59BA.
We can convert these to hard-coded pointers and free the space.