From ab2ca897ce3d0b4084fccebe400566a080d6e32c Mon Sep 17 00:00:00 2001 From: Arne Schmitz Date: Sun, 16 Mar 2025 17:04:25 +0100 Subject: [PATCH] pure asm implementation of bsplot --- include/conio.c | 108 +++++++++++++++++++++++++++++++----------------- 1 file changed, 71 insertions(+), 37 deletions(-) diff --git a/include/conio.c b/include/conio.c index 4a6014d..790be25 100644 --- a/include/conio.c +++ b/include/conio.c @@ -134,8 +134,77 @@ __asm bsinit #elif defined(__CBMPET__) #define bsout 0xffd2 #define bsin 0xffe4 -__asm bsplot{ - /* no equivalent on PET */ +/* This is inspired by the cc65 source code from pet/cputc.s */ +#define CURS_X $c6 +#define CURS_Y $d8 +#define SCREEN_PTR $c4 +#define SCR_LINELEN $d5 +__asm bsplot +{ + sty CURS_X + stx CURS_Y +plot: ldy CURS_Y + lda ScrLo,y + sta SCREEN_PTR + lda ScrHi,y + ldy SCR_LINELEN + cpy #40+1 + bcc col80 + asl SCREEN_PTR /* 80 column mode */ + rol +col80: ora #$80 /* Screen at $8000 */ + sta SCREEN_PTR+1 + rts +ScrLo: byt 0x00 + byt 0x28 + byt 0x50 + byt 0x78 + byt 0xA0 + byt 0xC8 + byt 0xF0 + byt 0x18 + byt 0x40 + byt 0x68 + byt 0x90 + byt 0xB8 + byt 0xE0 + byt 0x08 + byt 0x30 + byt 0x58 + byt 0x80 + byt 0xA8 + byt 0xD0 + byt 0xF8 + byt 0x20 + byt 0x48 + byt 0x70 + byt 0x98 + byt 0xC0 +ScrHi: byt 0x00 + byt 0x00 + byt 0x00 + byt 0x00 + byt 0x00 + byt 0x00 + byt 0x00 + byt 0x01 + byt 0x01 + byt 0x01 + byt 0x01 + byt 0x01 + byt 0x01 + byt 0x02 + byt 0x02 + byt 0x02 + byt 0x02 + byt 0x02 + byt 0x02 + byt 0x02 + byt 0x03 + byt 0x03 + byt 0x03 + byt 0x03 + byt 0x03 } __asm bsinit { @@ -352,40 +421,6 @@ void textcursor(bool show) void gotoxy(char cx, char cy) { -#ifdef __CBMPET__ - /* This is inspired by the cc65 source code from pet/cputc.s */ -#define CURS_X $c6 -#define CURS_Y $d8 -#define SCREEN_PTR $c4 -#define SCR_LINELEN $d5 - - static const char ScrLo[] = { 0x00, 0x28, 0x50, 0x78, 0xA0, 0xC8, 0xF0, 0x18, - 0x40, 0x68, 0x90, 0xB8, 0xE0, 0x08, 0x30, 0x58, - 0x80, 0xA8, 0xD0, 0xF8, 0x20, 0x48, 0x70, 0x98, - 0xC0 }; - - static const char ScrHi[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, - 0x03 }; - __asm { - lda cx - sta CURS_X - lda cy - sta CURS_Y - ldy CURS_Y - lda ScrLo,y - sta SCREEN_PTR - lda ScrHi,y - ldy SCR_LINELEN - cpy #40+1 - bcc col80 - asl SCREEN_PTR /* 80 column mode */ - rol - col80: ora #$80 /* Screen at $8000 */ - sta SCREEN_PTR+1 - } -#else __asm { ldx cy @@ -393,7 +428,6 @@ void gotoxy(char cx, char cy) clc jsr bsplot } -#endif } void textcolor(char c)