1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-26 10:49:17 +00:00
8bitworkshop/presets/zx/bios.c
2020-07-02 20:24:52 -05:00

69 lines
868 B
C

#include <stdio.h>
#ifdef __MAIN__
void main(void);
void startup(void) __naked {
__asm
jp _main
__endasm;
}
#endif
// http://www.users.globalnet.co.uk/~jg27paw4/pourri/rom-routines.txt
void init_stdio(void) {
__asm
ld a,#2
call 0x1601
__endasm;
}
int putchar(int ch) {
if (ch == 10) ch = 13; // newline -> CR
__asm
ld a,4 (ix)
rst 0x10
__endasm;
}
void beep(int divisor, int duration) {
divisor;
duration;
__asm
ld l,4 (ix)
ld h,5 (ix)
ld e,6 (ix)
ld d,7 (ix)
call 0x3b5
__endasm;
}
int keyscan(void) {
__asm
call 0x028e
ld l,e
ld h,d
__endasm;
}
#ifdef __MAIN__
void main() {
init_stdio();
printf("HELLO WORLD!\r");
beep(1000,20);
beep(750,20);
beep(500,20);
while (1) {
int key = keyscan();
if (key != -1) printf("%04x", key);
}
while (1);
}
#endif