This is currently very broken due to a map actor loader out of bounds
read
# Known Bugs
+## Map actor loads are happening far out of bounds
+
+This causes random values being read as actor data.
+This bug only manifested itself as code went beyond 0x22a2.
+
--- /dev/null
+demo_inputs1:
+; this file contains some demo-input recordings
+.db BTNLEFT, BTNLEFT, BTNLEFT, BTNLEFT, BTNLEFT, BTNLEFT, 0xFF
+
+ ; load demo ptr
+ ; inputs
+ ; hl: demo ptr
+ ; writes ptr to demo_inpiuts
+ load_demo_ptr:
+ ld l, a
+ ld [de], a
+ inc de
+ ld h, a
+ ld [de], a
+ ret
+
+ ; clears demo inputs
+clear_demo_ptr:
+ ld hl, demo_inputs
+ xor a, a
+ ld [hl+], a
+ ld [hl], a
+ ret
ld a, [curr_inputs]
and a, $1
#endmacro
-
+
+ ; TODO: if demo_inputs is set read from inputs instead of polling
; poll inputs
; returns:
; new inputs in [curr_inputs]
ld a, [curr_inputs]
ld [prev_inputs], a
+ ld a, [demo_inputs]
+ ld b, a
+ ld a, [demo_inputs+1]
+ or a, b
+ ; a == null?
+ jr nz, @read_demo_input REL
+
ld a, P1FDPAD
call poll_p1
swap a
ret
+@read_demo_input:
+ ; load ptr
+ ld de, demo_inputs
+ ld a, [de]
+ ld l, a
+ inc de
+ ld a, [de]
+ ld h, a ; hl = inputs
+ dec de
+
+ ld a, [hl+]
+ cp a, 0xFF ; is the list done?
+ jr z, @demo_done REL
+
+ ; sotre value
+ ld [curr_inputs], a
+
+ ; store new ptr
+ jp load_demo_ptr
+@demo_done:
+ xor a, a
+ ; clear inputs and ptr
+ ld [curr_inputs], a
+ jp clear_demo_ptr
+
; poll p1
; inputs:
#include "text.s"
#include "stats.s"
#include "actortables.s"
+#include "demos.s"
; fill bank
-.fill 0, 0x7FFF - $
+.fill 0xFF, 0x7FFF - $
ld bc, st_size
call memcpy
+ ; load a demo
+ ; ld hl, demo1
+ ; call load_demo_ptr
+
ret
game_init:
; status text buffer
status_text: .adv 32
+ ; ptr to demo inputs
+ ; provides one byte of inputs per frame
+ ; if all buttons are held (value is 0xFF) it indicates the end
+ ; of the input list
+ ; if set to NULL do not read from this address
+demo_inputs: .adv 2
+
; offset into bg_update_queue
bg_update_index: .adv 2
bg_update_queue: .adv bge_size * BGE_MAX