mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2025-04-09 05:44:44 -07:00
Merge branch 'master' into refactor-preprocessor
This commit is contained in:
commit
5c4dc08ee4
23
Makefile
23
Makefile
@ -1,3 +1,4 @@
|
||||
PYTHON := python
|
||||
.SUFFIXES: .asm .tx .o .gbc .png .2bpp .lz
|
||||
|
||||
TEXTFILES := $(shell find ./ -type f -name '*.asm' | grep -v pokecrystal.asm | grep -v constants.asm | grep -v gbhw.asm | grep -v hram.asm | grep -v constants | grep -v wram.asm)
|
||||
@ -13,36 +14,36 @@ clean:
|
||||
rm -f pokecrystal.o pokecrystal.gbc
|
||||
@echo 'rm -f $(TEXTFILES:.asm=.tx)'
|
||||
@rm -f $(TEXTFILES:.asm=.tx)
|
||||
pokecrystal.o: $(TEXTFILES:.asm=.tx) wram.asm constants.asm $(shell find constants/ -type f -name '*constants.asm') hram.asm gbhw.asm $(LZ_GFX) $(TWOBPP_GFX)
|
||||
python prequeue.py $(TEXTQUEUE)
|
||||
pokecrystal.o: $(TEXTFILES:.asm=.tx) wram.asm constants.asm $(shell find constants/ -type f -name '*.asm') hram.asm gbhw.asm $(LZ_GFX) $(TWOBPP_GFX)
|
||||
$(PYTHON) prequeue.py $(TEXTQUEUE)
|
||||
rgbasm -o pokecrystal.o pokecrystal.asm
|
||||
.asm.tx:
|
||||
$(eval TEXTQUEUE := $(TEXTQUEUE) $<)
|
||||
@rm -f $@
|
||||
baserom.gbc:
|
||||
python -c "import os; assert 'baserom.gbc' in os.listdir('.'), 'Wait! Need baserom.gbc first. Check README and INSTALL for details.';"
|
||||
$(PYTHON) -c "import os; assert 'baserom.gbc' in os.listdir('.'), 'Wait! Need baserom.gbc first. Check README and INSTALL for details.';"
|
||||
|
||||
pokecrystal.gbc: pokecrystal.o
|
||||
rgblink -n pokecrystal.sym -m pokecrystal.map -o $@ $<
|
||||
rgbfix -Cjv -i BYTE -k 01 -l 0x33 -m 0x10 -p 0 -r 3 -t PM_CRYSTAL $@
|
||||
|
||||
pngs:
|
||||
python extras/pokemontools/gfx.py mass-decompress
|
||||
python extras/pokemontools/gfx.py dump-pngs
|
||||
$(PYTHON) extras/pokemontools/gfx.py mass-decompress
|
||||
$(PYTHON) extras/pokemontools/gfx.py dump-pngs
|
||||
|
||||
lzs: $(LZ_GFX) $(TWOBPP_GFX)
|
||||
@:
|
||||
|
||||
gfx/pics/%/front.lz: gfx/pics/%/tiles.2bpp gfx/pics/%/front.png
|
||||
python extras/pokemontools/gfx.py png-to-lz --front $^
|
||||
$(PYTHON) extras/pokemontools/gfx.py png-to-lz --front $^
|
||||
gfx/pics/%/tiles.2bpp: gfx/pics/%/tiles.png
|
||||
python extras/pokemontools/gfx.py png-to-2bpp $<
|
||||
$(PYTHON) extras/pokemontools/gfx.py png-to-2bpp $<
|
||||
gfx/pics/%/back.lz: gfx/pics/%/back.png
|
||||
python extras/pokemontools/gfx.py png-to-lz --vert $<
|
||||
$(PYTHON) extras/pokemontools/gfx.py png-to-lz --vert $<
|
||||
gfx/trainers/%.lz: gfx/trainers/%.png
|
||||
python extras/pokemontools/gfx.py png-to-lz --vert $<
|
||||
$(PYTHON) extras/pokemontools/gfx.py png-to-lz --vert $<
|
||||
.png.lz:
|
||||
python extras/pokemontools/gfx.py png-to-lz $<
|
||||
$(PYTHON) extras/pokemontools/gfx.py png-to-lz $<
|
||||
.png.2bpp:
|
||||
python extras/pokemontools/gfx.py png-to-lz $<
|
||||
$(PYTHON) extras/pokemontools/gfx.py png-to-lz $<
|
||||
|
||||
|
@ -23,99 +23,7 @@ FarCall EQU $08
|
||||
Bankswitch EQU $10
|
||||
JumpTable EQU $28
|
||||
|
||||
|
||||
dwb: MACRO
|
||||
dw \1
|
||||
db \2
|
||||
ENDM
|
||||
|
||||
dbw: MACRO
|
||||
db \1
|
||||
dw \2
|
||||
ENDM
|
||||
|
||||
dn: MACRO
|
||||
db \1 << 4 + \2
|
||||
ENDM
|
||||
|
||||
dt: MACRO ; three-byte (big-endian)
|
||||
db (\1 >> 16) & $ff
|
||||
db (\1 >> 8) & $ff
|
||||
db \1 & $ff
|
||||
ENDM
|
||||
|
||||
bigdw: MACRO ; big-endian word
|
||||
dw ((\1)/$100) + (((\1)&$ff)*$100)
|
||||
ENDM
|
||||
|
||||
callab: MACRO ; address, bank
|
||||
ld hl, \1
|
||||
ld a, BANK(\1)
|
||||
rst FarCall
|
||||
ENDM
|
||||
|
||||
callba: MACRO ; bank, address
|
||||
ld a, BANK(\1)
|
||||
ld hl, \1
|
||||
rst FarCall
|
||||
ENDM
|
||||
|
||||
TX_RAM: MACRO
|
||||
db 1
|
||||
dw \1
|
||||
ENDM
|
||||
|
||||
TX_FAR: MACRO
|
||||
db $16
|
||||
dw \1
|
||||
db BANK(\1)
|
||||
ENDM
|
||||
|
||||
RGB: MACRO
|
||||
dw ((\3 << 10) | (\2 << 5) | (\1))
|
||||
ENDM
|
||||
|
||||
note: MACRO
|
||||
db \1
|
||||
ENDM
|
||||
|
||||
; It's better to use *coord than FuncCoord.
|
||||
FuncCoord: MACRO
|
||||
Coord = $c4a0 + 20 * \2 + \1
|
||||
ENDM
|
||||
|
||||
bccoord: MACRO
|
||||
FuncCoord \1, \2
|
||||
ld bc, Coord
|
||||
ENDM
|
||||
|
||||
decoord: MACRO
|
||||
FuncCoord \1, \2
|
||||
ld de, Coord
|
||||
ENDM
|
||||
|
||||
hlcoord: MACRO
|
||||
FuncCoord \1, \2
|
||||
ld hl, Coord
|
||||
ENDM
|
||||
|
||||
|
||||
; pic animations
|
||||
frame: MACRO
|
||||
db \1
|
||||
db \2
|
||||
ENDM
|
||||
setrepeat: MACRO
|
||||
db $fe
|
||||
db \1
|
||||
ENDM
|
||||
dorepeat: MACRO
|
||||
db $fd
|
||||
db \1
|
||||
ENDM
|
||||
endanim: MACRO
|
||||
db $ff
|
||||
ENDM
|
||||
INCLUDE "macros.asm"
|
||||
|
||||
|
||||
NONE EQU 0
|
||||
@ -283,6 +191,9 @@ SCREEN_HEIGHT EQU 18
|
||||
SCREEN_WIDTH_PX EQU 160
|
||||
SCREEN_HEIGHT_PX EQU 144
|
||||
|
||||
BG_MAP_WIDTH EQU 32
|
||||
BG_MAP_HEIGHT EQU 32
|
||||
|
||||
TILE_WIDTH EQU 8
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -248,13 +248,13 @@ Request2bpp: ; eba
|
||||
|
||||
.asm_edc
|
||||
ld a, e
|
||||
ld [$cf68], a
|
||||
ld [Requested2bppSource], a
|
||||
ld a, d
|
||||
ld [$cf69], a
|
||||
ld [Requested2bppSource + 1], a
|
||||
ld a, l
|
||||
ld [$cf6a], a
|
||||
ld [Requested2bppDest], a
|
||||
ld a, h
|
||||
ld [$cf6b], a
|
||||
ld [Requested2bppDest + 1], a
|
||||
|
||||
.asm_eec
|
||||
ld a, c
|
||||
@ -262,10 +262,10 @@ Request2bpp: ; eba
|
||||
cp [hl]
|
||||
jr nc, .asm_f08
|
||||
|
||||
ld [$cf67], a
|
||||
ld [Requested2bpp], a
|
||||
.wait
|
||||
call DelayFrame
|
||||
ld a, [$cf67]
|
||||
ld a, [Requested2bpp]
|
||||
and a
|
||||
jr nz, .wait
|
||||
|
||||
@ -281,10 +281,10 @@ Request2bpp: ; eba
|
||||
|
||||
.asm_f08
|
||||
ld a, [$ffd3]
|
||||
ld [$cf67], a
|
||||
ld [Requested2bpp], a
|
||||
.asm_f0d
|
||||
call DelayFrame
|
||||
ld a, [$cf67]
|
||||
ld a, [Requested2bpp]
|
||||
and a
|
||||
jr nz, .asm_f0d
|
||||
ld a, c
|
||||
@ -322,23 +322,23 @@ Request1bpp: ; f1e
|
||||
|
||||
.asm_f40
|
||||
ld a, e
|
||||
ld [$cf6d], a
|
||||
ld [Requested1bppSource], a
|
||||
ld a, d
|
||||
ld [$cf6e], a
|
||||
ld [Requested1bppSource + 1], a
|
||||
ld a, l
|
||||
ld [$cf6f], a
|
||||
ld [Requested1bppDest], a
|
||||
ld a, h
|
||||
ld [$cf70], a
|
||||
ld [Requested1bppDest + 1], a
|
||||
.asm_f50
|
||||
ld a, c
|
||||
ld hl, $ffd3
|
||||
cp [hl]
|
||||
jr nc, .asm_f6c
|
||||
|
||||
ld [$cf6c], a
|
||||
ld [Requested1bpp], a
|
||||
.wait
|
||||
call DelayFrame
|
||||
ld a, [$cf6c]
|
||||
ld a, [Requested1bpp]
|
||||
and a
|
||||
jr nz, .wait
|
||||
|
||||
@ -354,10 +354,10 @@ Request1bpp: ; f1e
|
||||
|
||||
.asm_f6c
|
||||
ld a, [$ffd3]
|
||||
ld [$cf6c], a
|
||||
ld [Requested1bpp], a
|
||||
.asm_f71
|
||||
call DelayFrame
|
||||
ld a, [$cf6c]
|
||||
ld a, [Requested1bpp]
|
||||
and a
|
||||
jr nz, .asm_f71
|
||||
ld a, c
|
||||
|
23
engine/delay.asm
Normal file
23
engine/delay.asm
Normal file
@ -0,0 +1,23 @@
|
||||
DelayFrame: ; 45a
|
||||
; Wait for one frame
|
||||
ld a, 1
|
||||
ld [VBlankOccurred], a
|
||||
|
||||
; Wait for the next VBlank, halting to conserve battery
|
||||
.halt
|
||||
halt ; rgbasm adds a nop after this instruction by default
|
||||
ld a, [VBlankOccurred]
|
||||
and a
|
||||
jr nz, .halt
|
||||
ret
|
||||
; 468
|
||||
|
||||
|
||||
DelayFrames: ; 468
|
||||
; Wait c frames
|
||||
call DelayFrame
|
||||
dec c
|
||||
jr nz, DelayFrames
|
||||
ret
|
||||
; 46f
|
||||
|
55
engine/farcall.asm
Normal file
55
engine/farcall.asm
Normal file
@ -0,0 +1,55 @@
|
||||
FarCall_de: ; 2d54
|
||||
; Call a:de.
|
||||
; Preserves other registers.
|
||||
|
||||
ld [hBuffer], a
|
||||
ld a, [hROMBank]
|
||||
push af
|
||||
ld a, [hBuffer]
|
||||
rst Bankswitch
|
||||
call .de
|
||||
jr ReturnFarCall
|
||||
|
||||
.de
|
||||
push de
|
||||
ret
|
||||
; 2d63
|
||||
|
||||
|
||||
FarCall_hl: ; 2d63
|
||||
; Call a:hl.
|
||||
; Preserves other registers.
|
||||
|
||||
ld [hBuffer], a
|
||||
ld a, [hROMBank]
|
||||
push af
|
||||
ld a, [hBuffer]
|
||||
rst Bankswitch
|
||||
call Function2d82
|
||||
; 2d6e
|
||||
|
||||
ReturnFarCall: ; 2d6e
|
||||
; We want to retain the contents of f.
|
||||
; To do this, we can pop to bc instead of af.
|
||||
|
||||
ld a, b
|
||||
ld [$cfb9], a
|
||||
ld a, c
|
||||
ld [$cfba], a
|
||||
|
||||
; Restore the working bank.
|
||||
pop bc
|
||||
ld a, b
|
||||
rst Bankswitch
|
||||
|
||||
ld a, [$cfb9]
|
||||
ld b, a
|
||||
ld a, [$cfba]
|
||||
ld c, a
|
||||
ret
|
||||
; 2d82
|
||||
|
||||
Function2d82: ; 2d82
|
||||
jp [hl]
|
||||
; 2d83
|
||||
|
132
engine/game_time.asm
Normal file
132
engine/game_time.asm
Normal file
@ -0,0 +1,132 @@
|
||||
ResetGameTime: ; 208a
|
||||
xor a
|
||||
ld [GameTimeCap], a
|
||||
ld [GameTimeHours], a
|
||||
ld [GameTimeHours + 1], a
|
||||
ld [GameTimeMinutes], a
|
||||
ld [GameTimeSeconds], a
|
||||
ld [GameTimeFrames], a
|
||||
ret
|
||||
; 209e
|
||||
|
||||
|
||||
GameTimer: ; 209e
|
||||
|
||||
nop
|
||||
|
||||
ld a, [rSVBK]
|
||||
push af
|
||||
ld a, 1
|
||||
ld [rSVBK], a
|
||||
|
||||
call UpdateGameTimer
|
||||
|
||||
pop af
|
||||
ld [rSVBK], a
|
||||
ret
|
||||
; 20ad
|
||||
|
||||
|
||||
UpdateGameTimer: ; 20ad
|
||||
; Increment the game timer by one frame.
|
||||
; The game timer is capped at 999:59:59.00.
|
||||
|
||||
|
||||
; Don't update if game logic is paused.
|
||||
ld a, [$c2cd]
|
||||
and a
|
||||
ret nz
|
||||
|
||||
; Is the timer paused?
|
||||
ld hl, GameTimerPause
|
||||
bit 0, [hl]
|
||||
ret z
|
||||
|
||||
; Is the timer already capped?
|
||||
ld hl, GameTimeCap
|
||||
bit 0, [hl]
|
||||
ret nz
|
||||
|
||||
|
||||
; +1 frame
|
||||
ld hl, GameTimeFrames
|
||||
ld a, [hl]
|
||||
inc a
|
||||
|
||||
cp 60 ; frames/second
|
||||
jr nc, .second
|
||||
|
||||
ld [hl], a
|
||||
ret
|
||||
|
||||
|
||||
.second
|
||||
xor a
|
||||
ld [hl], a
|
||||
|
||||
; +1 second
|
||||
ld hl, GameTimeSeconds
|
||||
ld a, [hl]
|
||||
inc a
|
||||
|
||||
cp 60 ; seconds/minute
|
||||
jr nc, .minute
|
||||
|
||||
ld [hl], a
|
||||
ret
|
||||
|
||||
|
||||
.minute
|
||||
xor a
|
||||
ld [hl], a
|
||||
|
||||
; +1 minute
|
||||
ld hl, GameTimeMinutes
|
||||
ld a, [hl]
|
||||
inc a
|
||||
|
||||
cp 60 ; minutes/hour
|
||||
jr nc, .hour
|
||||
|
||||
ld [hl], a
|
||||
ret
|
||||
|
||||
|
||||
.hour
|
||||
xor a
|
||||
ld [hl], a
|
||||
|
||||
; +1 hour
|
||||
ld a, [GameTimeHours]
|
||||
ld h, a
|
||||
ld a, [GameTimeHours + 1]
|
||||
ld l, a
|
||||
inc hl
|
||||
|
||||
|
||||
; Cap the timer after 1000 hours.
|
||||
ld a, h
|
||||
cp 1000 / $100
|
||||
jr c, .ok
|
||||
|
||||
ld a, l
|
||||
cp 1000 % $100
|
||||
jr c, .ok
|
||||
|
||||
ld hl, GameTimeCap
|
||||
set 0, [hl]
|
||||
|
||||
ld a, 59 ; 999:59:59.00
|
||||
ld [GameTimeMinutes], a
|
||||
ld [GameTimeSeconds], a
|
||||
ret
|
||||
|
||||
|
||||
.ok
|
||||
ld a, h
|
||||
ld [GameTimeHours], a
|
||||
ld a, l
|
||||
ld [GameTimeHours + 1], a
|
||||
ret
|
||||
; 210f
|
||||
|
683
engine/map_objects.asm
Normal file
683
engine/map_objects.asm
Normal file
File diff suppressed because it is too large
Load Diff
603
engine/menu.asm
Normal file
603
engine/menu.asm
Normal file
File diff suppressed because it is too large
Load Diff
25
engine/rtc.asm
Normal file
25
engine/rtc.asm
Normal file
@ -0,0 +1,25 @@
|
||||
RTC: ; 46f
|
||||
; update time and time-sensitive palettes
|
||||
|
||||
; rtc enabled?
|
||||
ld a, [$c2ce]
|
||||
cp 0
|
||||
ret z
|
||||
|
||||
call UpdateTime
|
||||
|
||||
; obj update on?
|
||||
ld a, [VramState]
|
||||
bit 0, a ; obj update
|
||||
ret z
|
||||
|
||||
TimeOfDayPals: ; 47e
|
||||
callab _TimeOfDayPals
|
||||
ret
|
||||
; 485
|
||||
|
||||
UpdateTimePals: ; 485
|
||||
callab _UpdateTimePals
|
||||
ret
|
||||
; 48c
|
||||
|
22
engine/sine.asm
Normal file
22
engine/sine.asm
Normal file
@ -0,0 +1,22 @@
|
||||
Cosine: ; 1b0f
|
||||
; Return d * cos(a) in hl
|
||||
add $10 ; 90 degrees
|
||||
|
||||
Sine: ; 1b11
|
||||
; Return d * sin(a) in hl
|
||||
; a is a signed 6-bit value.
|
||||
|
||||
ld e, a
|
||||
|
||||
ld a, [hROMBank]
|
||||
push af
|
||||
ld a, BANK(_Sine)
|
||||
rst Bankswitch
|
||||
|
||||
call _Sine
|
||||
|
||||
pop af
|
||||
rst Bankswitch
|
||||
ret
|
||||
; 1b1e
|
||||
|
@ -155,6 +155,7 @@ Function1052: ; 1052
|
||||
|
||||
PrintText: ; 1057
|
||||
call Function106c
|
||||
Function105a: ; 105a
|
||||
push hl
|
||||
hlcoord 1, 14
|
||||
ld bc, 18 + 3<<8
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user