Re: Sending input via joypad using 8F
Posted by: Exegutt0r
Date: 2016-08-27 00:28:17
Glitch City Laboratories closed on 1 September 2020 (announcement). This is an archived copy of a thread from Glitch City Laboratories Forums.
You can join Glitch City Research Institute to ask questions or discuss current developments.
You may also download the archive of this forum in .tar.gz, .sql.gz, or .sqlite.gz formats.
; When loading the game, only SRAM bank 0 can be accessed, and all ROM banks can be reached. (MBC1 is on banking mode 0)
; We just need to open up the SRAM edition. That's doable, I s'pose.
; No function in the game simply opens SRAM ; they all close it later on :(
ld a, $0A ; Any non-$0A value locks SRAM. That's safe, but unfortunately that isn't quite nice for us >.>
; Right now, hl = D322. We need to write to anywhere between 0000 and 1FFF to enable SRAM.
ld h, $01 ; Now, hl = 0122, which is in the above range.
ld [hli], a ; *Zelda item get theme* You got the SRAM PASS ! You can now sail to the A000 - BFFF range !
; hl = 0123 now.
inc b ; filler !
ld hl, ??58
inc b
adc a, $AE ; All flags should be reset : a = B8
inc/dec h ; Doesn't matter.
ld h, a ; hl = B858. Phew.
; d should be 0. Convenience !
; Now, THIS is the main loop.
mainloop:
call Joypad ; Joypad is at 019A. That means MASTER BALL ?? Crap.
; WARNING : destroys a, b and e !
inc b
ld a, [$FF00 + $B3] ; We fetch hJoyPressed (the keys pressed since the last Joypad call).
inc b ; Filleeeerrrrr !!1
rla ; Down
INSERT FILLER
jr nc, $+4
ld e, a
ld a, d
ld [hli], a ; Push one byte down the stream !
ld a, e
rla ; Up
jr nc, $+2
inc d ; Increment d
rla ; Left
jr nc, $+2
sla d ; Double d
rla ; Right
Anything x[any qty] ; Really, it does NOT (NOT (NOT matter)) at this point.
8F
Lemonade x10
Carbos x1
Water Stone x4
Thunder Stone x88
[any item] x4
TM06 x174
Protein/Iron x103 ; here, the bootstrap is complete. We still have 11 items to go !
; mainloop
TM05 x154
Master Ball x4 ; C'mon, don't tell me you didn't dupe them ???
TM40 x179
Poké Ball x22
INSERT FILLER