add conio.h

This commit is contained in:
drmortalwombat 2021-09-13 20:55:31 +02:00
parent 913f0d4190
commit 9f8362255f
4 changed files with 141 additions and 14 deletions

108
include/conio.c Normal file
View File

@ -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
}
}

25
include/conio.h Normal file
View File

@ -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

View File

@ -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

View File

@ -65,7 +65,7 @@ void Emulator::DumpCycles(void)
}
printf("Total Cycles %d\n", totalCycles);
return;
// return;
for (int i = 0; i < numTops; i++)
{