Skip to content

Commit

Permalink
c64.h: add c64_basic_run() and c64_basic_load() helper functions
Browse files Browse the repository at this point in the history
  • Loading branch information
floooh committed Dec 28, 2023
1 parent e4059f4 commit fc57a3b
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions systems/c64.h
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,12 @@ bool c64_is_tape_motor_on(c64_t* sys);
uint32_t c64_save_snapshot(c64_t* sys, c64_t* dst);
// load a snapshot, returns false if snapshot versions don't match
bool c64_load_snapshot(c64_t* sys, uint32_t version, c64_t* src);
// perform a SYS xxxx BASIC call
void c64_syscall(c64_t* sys, uint16_t addr);
// perform a RUN BASIC call
void c64_basic_run(c64_t* sys);
// perform a LOAD BASIC call
void c64_basic_load(c64_t* sys);
// perform a SYS xxxx BASIC call via the BASIC input buffer
void c64_basic_syscall(c64_t* sys, uint16_t addr);
// returns the SYS call return address (can be used to set a breakpoint)
uint16_t c64_syscall_return_addr(void);

Expand Down Expand Up @@ -1167,7 +1171,32 @@ bool c64_load_snapshot(c64_t* sys, uint32_t version, c64_t* src) {
return true;
}

void c64_syscall(c64_t* sys, uint16_t addr) {
void c64_basic_run(c64_t* sys) {
CHIPS_ASSERT(sys);
// write RUN into the keyboard buffer
uint16_t keybuf = 0x277;
mem_wr(&sys->mem_cpu, keybuf++, 'R');
mem_wr(&sys->mem_cpu, keybuf++, 'U');
mem_wr(&sys->mem_cpu, keybuf++, 'N');
mem_wr(&sys->mem_cpu, keybuf++, 0x0D);
// write number of characters, this kicks off evaluation
mem_wr(&sys->mem_cpu, 0xC6, 4);
}

void c64_basic_load(c64_t* sys) {
CHIPS_ASSERT(sys);
// write LOAD
uint16_t keybuf = 0x277;
mem_wr(&sys->mem_cpu, keybuf++, 'L');
mem_wr(&sys->mem_cpu, keybuf++, 'O');
mem_wr(&sys->mem_cpu, keybuf++, 'A');
mem_wr(&sys->mem_cpu, keybuf++, 'D');
mem_wr(&sys->mem_cpu, keybuf++, 0x0D);
// write number of characters, this kicks off evaluation
mem_wr(&sys->mem_cpu, 0xC6, 5);
}

void c64_basic_syscall(c64_t* sys, uint16_t addr) {
CHIPS_ASSERT(sys);
// write SYS xxxx[Return] into the keyboard buffer (up to 10 chars)
uint16_t keybuf = 0x277;
Expand Down

0 comments on commit fc57a3b

Please sign in to comment.