- File transfer using only keyboard input
- 19 Oct 2015 03:28:57 pm
- Last edited by haveacalc on 19 Oct 2015 06:41:14 pm; edited 1 time in total
Hey all, long time no see. I'm a TASer these days, and recently, someone submitted a TAS of a TI-83 game for the first time ever. One of the challenges of a TI-XX TAS is making the game load. Unlike an actual console, which loads any (acceptable) game from a cartridge, a calculator game already exists in the RAM or flash when you wake up your calculator up to play it. Starting the movie file from fresh RAM is preferred on all consoles; starting from a savestate is generally frowned upon if there is an alternative.
The runner, dwangoAC, worked around this by typing in the (BASIC) game live in his TAS before playing the game itself. I was able to improve his time significantly by making a Lua script/z80 assembly combo that basically does the following:
1) Uses the keypad to type in the opcodes for a routine that writes keypad inputs to memory (I chose SaveSScreen) and then jumps to it
2) Type in the data for a second ASM routine this way, along with the token data for the BASIC program.
3) Run the second ASM routine, which makes a new program variable with the BASIC data and runs it
The thing is, step 2 is pretty slow. Right now, data transfers at a rate of 4 bits per frame (at 61 FPS, 10000 cycles per frame). Would I be better off doing all of this over the link port, or can it still be faster to input the data over the keypad?
All code is hosted on GitGud. Half is shamelessly ripped from AsmGuru.
Routine for part 1:
Code:
The runner, dwangoAC, worked around this by typing in the (BASIC) game live in his TAS before playing the game itself. I was able to improve his time significantly by making a Lua script/z80 assembly combo that basically does the following:
1) Uses the keypad to type in the opcodes for a routine that writes keypad inputs to memory (I chose SaveSScreen) and then jumps to it
2) Type in the data for a second ASM routine this way, along with the token data for the BASIC program.
3) Run the second ASM routine, which makes a new program variable with the BASIC data and runs it
The thing is, step 2 is pretty slow. Right now, data transfers at a rate of 4 bits per frame (at 61 FPS, 10000 cycles per frame). Would I be better off doing all of this over the link port, or can it still be faster to input the data over the keypad?
All code is hosted on GitGud. Half is shamelessly ripped from AsmGuru.
Routine for part 1:
Code:
ld hl, PayloadAddress
ld d, outerCount
KeyLoop:
call GetInput
add a, a
add a, a
add a, a
add a, a
ld c, a
ld a, h ; It has been counting down
cp $00
jp z, PayloadAddress
call GetInput
or c
ld (hl), a
inc hl
jr KeyLoop
GetInput:
ld b, haltCount
dec d
jr nz, HaltLoop
ld d, outerCount
dec b ; Skip one
HaltLoop: ;Bizhawk counts 10000 cycles as 1 frame,
halt ;this syncs up with that pretty well
djnz HaltLoop
ld a, (kbdScanCode)
GetAHalfByte:
sub scanCodeOffset
cp emptyConvertedScanCode
jr nz, KeepGoing
NullInput:
ld h, 0
KeepGoing:
ld e, a
srl a
and $8
or e
and $0f
ret
.org SaveSScreen
PayloadAddress: