/* Public domain. Adapted from Pierre Sarrazin's autostart.c 0.1.2 (2018-08-04). * http://sarrazip.com/ -- Roger Schrag, The Rainbow, Nov 1984, p.140. * DOS feeds an ordinary Disk BASIC command; no emulator-specific loader. */ #include static byte oldHookInstr; static word oldHookAddr; static const char *basicLineReader; void feedKeyboard(void) { word preservedX; byte nextBasicByte; asm("stx", preservedX); *(byte *)0x70=0; nextBasicByte=*basicLineReader++; if(!nextBasicByte) { *(byte *)0x016A=oldHookInstr; *(word *)0x016B=oldHookAddr; nextBasicByte='\r'; } asm { lda nextBasicByte ldx preservedX tfr u,s leas 4,s rts } } int main(void) { *(byte *)0=-*(byte *)0; basicLineReader="PCLEAR1:CLEAR32:LOADM\"SOUNDLAB\":EXEC"; oldHookInstr=*(byte *)0x016A; oldHookAddr=*(word *)0x016B; *(byte *)0x016A=0x7E; *(void **)0x016B=(void *)feedKeyboard; *(word *)0x2600=0; asm("jmp", "$ac7c"); return 0; }