From 9f8362255f622148a19831481e4ec9a628c0372b Mon Sep 17 00:00:00 2001 From: drmortalwombat <90205530+drmortalwombat@users.noreply.github.com> Date: Mon, 13 Sep 2021 20:55:31 +0200 Subject: [PATCH] add conio.h --- include/conio.c | 108 +++++++++++++++++++++++++++++++++++++++++++ include/conio.h | 25 ++++++++++ include/crt.c | 20 +++----- oscar64/Emulator.cpp | 2 +- 4 files changed, 141 insertions(+), 14 deletions(-) create mode 100644 include/conio.c create mode 100644 include/conio.h diff --git a/include/conio.c b/include/conio.c new file mode 100644 index 0000000..17ce854 --- /dev/null +++ b/include/conio.c @@ -0,0 +1,108 @@ +#include "conio.h" + +int kbhit(void) +{ + __asm + { + lda $c6 + sta 0x1b + lda #0 + sta 0x1c + } +} + +int getche(void) +{ + __asm + { + L1: + jsr $ffe4 + cmp #0 + beq L1 + + sta 0x1b + jsr $ffd2 + lda #0 + sta 0x1c + } + +} + +int getch(void) +{ + __asm + { + L1: + jsr $ffe4 + cmp #0 + beq L1 + + sta 0x1b + lda #0 + sta 0x1c + } +} + +void putch(int c) +{ + __asm { + ldy #c + lda (fp), y + jsr 0xffd2 + } +} + +void clrscr(void) +{ + __asm + { + jsr $ff5b + } +} + +void gotoxy(int x, int y) +{ + __asm + { + ldy #y + lda (fp), y + tax + ldy #x + lda (fp), y + tay + clc + jsr $fff0 + } +} + +void textcolor(int c) +{ + __asm + { + ldy #c + lda (fp), y + sta $0286 + } +} + +int wherex(void) +{ + __asm + { + lda $d3 + sta 0x1b + lda #0 + sta 0x1c + } +} + +int wherey(void) +{ + __asm + { + lda $d6 + sta 0x1b + lda #0 + sta 0x1c + } +} diff --git a/include/conio.h b/include/conio.h new file mode 100644 index 0000000..bb55fe1 --- /dev/null +++ b/include/conio.h @@ -0,0 +1,25 @@ +#ifndef CONIO_H +#define CONIO_H + +int kbhit(void); + +int getche(void); + +int getch(void); + +void putch(int c); + +void clrscr(void); + +void gotoxy(int x, int y); + +void textcolor(int c); + +int wherex(void); + +int wherey(void); + +#pragma compile("conio.c") + +#endif + diff --git a/include/crt.c b/include/crt.c index 3047305..07aad59 100644 --- a/include/crt.c +++ b/include/crt.c @@ -2162,9 +2162,16 @@ W2: ldy accu lda tmp + bne W4 + lda tmp + 1 + beq W5 + bne W6 +W4: jsr fmul8 lda tmp + 1 +W6: jsr fmul8 +W5: lda tmp + 2 jsr fmul8 @@ -2615,19 +2622,6 @@ W2: rts } -#pragma runtime(fsplita, freg.split_aexp) -#pragma runtime(fsplitt, freg.split_texp) -#pragma runtime(fmergea, freg.merge_aexp) -#pragma runtime(faddsub, faddsub) -#pragma runtime(fmul, fmul) -#pragma runtime(fdiv, fdiv) -#pragma runtime(fcmp, fcmp) -#pragma runtime(ffromi, sint16_to_float) -#pragma runtime(ffromu, uint16_to_float) -#pragma runtime(ftoi, f32_to_i16) -#pragma runtime(ftou, f32_to_u16) - - __asm inp_conv_f32_u16 { jsr f32_to_u16 diff --git a/oscar64/Emulator.cpp b/oscar64/Emulator.cpp index 447a91b..c1cce7e 100644 --- a/oscar64/Emulator.cpp +++ b/oscar64/Emulator.cpp @@ -65,7 +65,7 @@ void Emulator::DumpCycles(void) } printf("Total Cycles %d\n", totalCycles); - return; +// return; for (int i = 0; i < numTops; i++) {