mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-11-16 21:07:56 +00:00
- kbhit() test is working and returns a character.
- fine tuned the veralayers.c demonstration program. - fine tuned clearline(), which will clear the current line of conio_cursor_y and reposition x at the start of the line.
This commit is contained in:
parent
9fd668bba5
commit
cdf564574a
124
src/main/fragment/cache/fragment-cache-wdc65c02.asm
vendored
124
src/main/fragment/cache/fragment-cache-wdc65c02.asm
vendored
@ -2191,3 +2191,127 @@ sta {c1}
|
||||
tya
|
||||
and {c1}
|
||||
sta {c1}
|
||||
//FRAGMENT vbuz1=_bnot_vbuz2
|
||||
lda {z2}
|
||||
eor #$ff
|
||||
sta {z1}
|
||||
//FRAGMENT vbuz1=_bnot_vbuaa
|
||||
eor #$ff
|
||||
sta {z1}
|
||||
//FRAGMENT vbuz1=_bnot_vbuxx
|
||||
txa
|
||||
eor #$ff
|
||||
sta {z1}
|
||||
//FRAGMENT vbuz1=_bnot_vbuyy
|
||||
tya
|
||||
eor #$ff
|
||||
sta {z1}
|
||||
//FRAGMENT vbuaa=_bnot_vbuz1
|
||||
lda {z1}
|
||||
eor #$ff
|
||||
//FRAGMENT vbuaa=_bnot_vbuaa
|
||||
eor #$ff
|
||||
//FRAGMENT vbuaa=_bnot_vbuxx
|
||||
txa
|
||||
eor #$ff
|
||||
//FRAGMENT vbuaa=_bnot_vbuyy
|
||||
tya
|
||||
eor #$ff
|
||||
//FRAGMENT vbuxx=_bnot_vbuz1
|
||||
lda {z1}
|
||||
eor #$ff
|
||||
tax
|
||||
//FRAGMENT vbuxx=_bnot_vbuaa
|
||||
eor #$ff
|
||||
tax
|
||||
//FRAGMENT vbuxx=_bnot_vbuxx
|
||||
txa
|
||||
eor #$ff
|
||||
tax
|
||||
//FRAGMENT vbuxx=_bnot_vbuyy
|
||||
tya
|
||||
eor #$ff
|
||||
tax
|
||||
//FRAGMENT vbuyy=_bnot_vbuz1
|
||||
lda {z1}
|
||||
eor #$ff
|
||||
tay
|
||||
//FRAGMENT vbuyy=_bnot_vbuaa
|
||||
eor #$ff
|
||||
tay
|
||||
//FRAGMENT vbuyy=_bnot_vbuxx
|
||||
txa
|
||||
eor #$ff
|
||||
tay
|
||||
//FRAGMENT vbuyy=_bnot_vbuyy
|
||||
tya
|
||||
eor #$ff
|
||||
tay
|
||||
//FRAGMENT vbuc1_lt_vbuz1_then_la1
|
||||
lda #{c1}
|
||||
cmp {z1}
|
||||
bcc {la1}
|
||||
//FRAGMENT vbuz1=pbuz2_derefidx_vbuz3
|
||||
ldy {z3}
|
||||
lda ({z2}),y
|
||||
sta {z1}
|
||||
//FRAGMENT vbuaa=pbuz1_derefidx_vbuz2
|
||||
ldy {z2}
|
||||
lda ({z1}),y
|
||||
//FRAGMENT vbuxx=pbuz1_derefidx_vbuz2
|
||||
ldy {z2}
|
||||
lda ({z1}),y
|
||||
tax
|
||||
//FRAGMENT vbuyy=pbuz1_derefidx_vbuz2
|
||||
ldy {z2}
|
||||
lda ({z1}),y
|
||||
tay
|
||||
//FRAGMENT vbuz1=pbuz2_derefidx_vbuaa
|
||||
tay
|
||||
lda ({z2}),y
|
||||
sta {z1}
|
||||
//FRAGMENT vbuaa=pbuz1_derefidx_vbuaa
|
||||
tay
|
||||
lda ({z1}),y
|
||||
//FRAGMENT vbuxx=pbuz1_derefidx_vbuaa
|
||||
tay
|
||||
lda ({z1}),y
|
||||
tax
|
||||
//FRAGMENT vbuyy=pbuz1_derefidx_vbuaa
|
||||
tay
|
||||
lda ({z1}),y
|
||||
tay
|
||||
//FRAGMENT vbuz1=pbuz2_derefidx_vbuxx
|
||||
txa
|
||||
tay
|
||||
lda ({z2}),y
|
||||
sta {z1}
|
||||
//FRAGMENT vbuaa=pbuz1_derefidx_vbuxx
|
||||
txa
|
||||
tay
|
||||
lda ({z1}),y
|
||||
//FRAGMENT vbuxx=pbuz1_derefidx_vbuxx
|
||||
txa
|
||||
tay
|
||||
lda ({z1}),y
|
||||
tax
|
||||
//FRAGMENT vbuyy=pbuz1_derefidx_vbuxx
|
||||
txa
|
||||
tay
|
||||
lda ({z1}),y
|
||||
tay
|
||||
//FRAGMENT vbuz1=pbuz2_derefidx_vbuyy
|
||||
lda ({z2}),y
|
||||
sta {z1}
|
||||
//FRAGMENT vbuaa=pbuz1_derefidx_vbuyy
|
||||
lda ({z1}),y
|
||||
//FRAGMENT vbuxx=pbuz1_derefidx_vbuyy
|
||||
lda ({z1}),y
|
||||
tax
|
||||
//FRAGMENT vbuyy=pbuz1_derefidx_vbuyy
|
||||
lda ({z1}),y
|
||||
tay
|
||||
//FRAGMENT vwuz1=_word_vbuaa
|
||||
sta {z1}
|
||||
lda #0
|
||||
sta {z1}+1
|
||||
|
@ -45,12 +45,46 @@ void conio_x16_init() {
|
||||
|
||||
// Return true if there's a key waiting, return false if not
|
||||
unsigned char kbhit(void) {
|
||||
// CIA#1 Port A: keyboard matrix columns and joystick #2
|
||||
char* const CIA1_PORT_A = 0xdc00;
|
||||
// CIA#1 Port B: keyboard matrix rows and joystick #1.
|
||||
char* const CIA1_PORT_B = 0xdc01;
|
||||
*CIA1_PORT_A = 0;
|
||||
return ~*CIA1_PORT_B;
|
||||
|
||||
char ch = 0;
|
||||
char* chptr = &ch;
|
||||
|
||||
char* IN_DEV = $028A; // Current input device number
|
||||
char* GETIN = $FFE4; // CBM GETIN API
|
||||
|
||||
kickasm(uses chptr, uses IN_DEV, uses GETIN) {{
|
||||
|
||||
jsr _kbhit
|
||||
bne L3
|
||||
|
||||
jmp continue1
|
||||
|
||||
.var via1 = $9f60 //VIA#1
|
||||
.var d1pra = via1+1
|
||||
|
||||
_kbhit:
|
||||
ldy d1pra // The count of keys pressed is stored in RAM bank 0.
|
||||
stz d1pra // Set d1pra to zero to access RAM bank 0.
|
||||
lda $A00A // Get number of characters from this address in the ROM of the CX16 (ROM 38).
|
||||
sty d1pra // Set d1pra to previous value.
|
||||
rts
|
||||
|
||||
L3:
|
||||
ldy IN_DEV // Save current input device
|
||||
stz IN_DEV // Keyboard
|
||||
phy
|
||||
jsr GETIN // Read char, and return in .A
|
||||
ply
|
||||
sta chptr // Store the character read in ch
|
||||
sty IN_DEV // Restore input device
|
||||
ldx #>$0000
|
||||
rts
|
||||
|
||||
continue1:
|
||||
nop
|
||||
}}
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
||||
// Set the color for the background. The old color setting is returned.
|
||||
@ -283,10 +317,12 @@ void cputln() {
|
||||
|
||||
void clearline() {
|
||||
// Select DATA0
|
||||
unsigned byte* conio_addr = CONIO_SCREEN_TEXT;
|
||||
conio_addr += conio_cursor_y*256;
|
||||
*VERA_CTRL &= ~VERA_ADDRSEL;
|
||||
// Set address
|
||||
*VERA_ADDRX_L = <conio_line_text;
|
||||
*VERA_ADDRX_M = >conio_line_text;
|
||||
*VERA_ADDRX_L = <conio_addr;
|
||||
*VERA_ADDRX_M = >conio_addr;
|
||||
*VERA_ADDRX_H = VERA_INC_1;
|
||||
char color = ( conio_backcolor << 4 ) | conio_textcolor;
|
||||
for( unsigned int c=0;c<CONIO_WIDTH; c++ ) {
|
||||
@ -294,6 +330,7 @@ void clearline() {
|
||||
*VERA_DATA0 = ' ';
|
||||
*VERA_DATA0 = color;
|
||||
}
|
||||
conio_cursor_x = 0;
|
||||
}
|
||||
|
||||
// Insert a new line, and scroll the lower part of the screen down.
|
||||
|
@ -1,53 +1,99 @@
|
||||
#include <printf.h>
|
||||
|
||||
void main() {
|
||||
textcolor(BLUE);
|
||||
|
||||
textcolor(WHITE);
|
||||
backcolor(BLACK);
|
||||
clrscr();
|
||||
// This statement sets the base of the display layer 1 at VRAM address 0x0200
|
||||
setscreenlayermapbase(0,0x20);
|
||||
screenlayer(0);
|
||||
clrscr();
|
||||
|
||||
|
||||
screenlayer(1);
|
||||
|
||||
gotoxy(0,0);
|
||||
|
||||
gotoxy(0,16);
|
||||
textcolor(RED);
|
||||
unsigned int width = screensizex();
|
||||
unsigned int height = screensizey();
|
||||
printf("vera card width = %u; height = %u\n", width, height);
|
||||
|
||||
printf("dc video = %x\n", *VERA_DC_VIDEO);
|
||||
printf("vera card layer 0 enabled = %x\n", screenlayerenabled(0));
|
||||
printf("vera card mapbase layer 0 = %x\n", getscreenlayermapbase(0));
|
||||
printf("l0 config = %x\n", *VERA_L0_CONFIG);
|
||||
printf("l0 tilebase = %x\n", *VERA_L0_TILEBASE);
|
||||
printf("l0 vscroll l = %x\n", *VERA_L0_HSCROLL_L);
|
||||
printf("l0 vscroll h = %x\n", *VERA_L0_HSCROLL_H);
|
||||
printf("vera card layer 1 enabled = %x\n", screenlayerenabled(1));
|
||||
printf("vera card mapbase layer 1 = %x\n", getscreenlayermapbase(1));
|
||||
printf("l1 config = %x\n", *VERA_L1_CONFIG);
|
||||
printf("l1 tilebase = %x\n", *VERA_L1_TILEBASE);
|
||||
printf("l1 vscroll l = %x\n", *VERA_L1_HSCROLL_L);
|
||||
printf("l1 vscroll h = %x\n", *VERA_L1_HSCROLL_H);
|
||||
|
||||
textcolor(BLUE);
|
||||
//disablescreenlayer1();
|
||||
screenlayerenable(0);
|
||||
printf("dc video = %x\n", *VERA_DC_VIDEO);
|
||||
printf("vera card layer 0 enabled = %x\n", screenlayerenabled(0));
|
||||
printf("vera card layer 1 enabled = %x\n", screenlayerenabled(1));
|
||||
printf("vera card mapbase layer 0 = %x\n", getscreenlayermapbase(0));
|
||||
printf("vera card mapbase layer 1 = %x\n", getscreenlayermapbase(1));
|
||||
printf("vera card mapbase layer 1 = %x\n", getscreenlayermapbase(1));
|
||||
|
||||
screenlayer(0);
|
||||
gotoxy(0,0);
|
||||
textcolor(GREEN);
|
||||
|
||||
printf("this program demonstrates the layer functionality in text mode.\n");
|
||||
|
||||
// Here we use the screensizex and screensizey functions to show the width and height of the text screen.
|
||||
printf("vera card width = %u; height = %u\n", screensizex(), screensizey());
|
||||
|
||||
// This is the content of the main controller registers of the VERA of layer 1.
|
||||
// Layer 1 is the default layer that is activated in the CX16 at startup.
|
||||
// It displays the characters in 1BPP 16x16 color mode!
|
||||
printf("vera dc video = %x\n", *VERA_DC_VIDEO);
|
||||
printf("vera layer 1 config = %x\n", *VERA_L1_CONFIG);
|
||||
printf("vera layer 1 enabled = %x\n", screenlayerenabled(1));
|
||||
printf("vera layer 1 mapbase = %x, tilebase = %x\n", getscreenlayermapbase(1), *VERA_L1_TILEBASE);
|
||||
printf("vera layer 1 vscroll high = %x, low = %x\n", *VERA_L1_HSCROLL_H, *VERA_L1_HSCROLL_L);
|
||||
|
||||
// Wait for a keypress and after clear the line!
|
||||
textcolor(YELLOW);
|
||||
printf("press a key");
|
||||
while(!kbhit());
|
||||
clearline();
|
||||
|
||||
// Now we continue with demonstrating the layering!
|
||||
// We set the mapbase of layer 0 to an address in VRAM.
|
||||
// We copy the tilebase address from layer 1, so that we reference to the same tilebase.
|
||||
// We print a text on layer 0, which of course, won't yet be displayed,
|
||||
// because we haven't activated layer 0 on the VERA.
|
||||
// But the text will be printed and awaiting to be displayer later, once we activate layer 0!
|
||||
// But first, we also print the layer 0 VERA configuration.
|
||||
// This statement sets the base of the display layer 1 at VRAM address 0x0200
|
||||
|
||||
setscreenlayermapbase(0,0x20); // Set the map base to address 0x04000
|
||||
*VERA_L0_CONFIG = *VERA_L1_CONFIG;
|
||||
*VERA_L0_TILEBASE = *VERA_L1_TILEBASE;
|
||||
printf("this is printed on layer 0");
|
||||
|
||||
//screenlayerdisable(0);
|
||||
printf("vera dc video = %x\n", *VERA_DC_VIDEO);
|
||||
printf("vera layer 0 config = %x\n", *VERA_L0_CONFIG);
|
||||
printf("vera layer 0 enabled = %x\n", screenlayerenabled(0));
|
||||
printf("vera layer 0 mapbase = %x, tilebase = %x\n", getscreenlayermapbase(0), *VERA_L0_TILEBASE);
|
||||
printf("vera layer 0 vscroll high = %x, low = %x\n", *VERA_L0_HSCROLL_H, *VERA_L0_HSCROLL_L);
|
||||
|
||||
// Now we print the layer 0 text on the layer 0!
|
||||
screenlayer(0); // We set conio to output to layer 0 instead of layer 1!
|
||||
clrscr(); // We clear the screen of layer 0!
|
||||
textcolor(BLUE);
|
||||
backcolor(WHITE);
|
||||
gotoxy(19,4);
|
||||
printf(" ");
|
||||
gotoxy(19,5);
|
||||
printf(" this is printed on layer 0 !!! ");
|
||||
gotoxy(19,6);
|
||||
printf(" ");
|
||||
|
||||
gotoxy(0,40);
|
||||
|
||||
screenlayer(1); // Now we ask conio again to output to layer 1!
|
||||
|
||||
// Wait for a keypress and after clear the line!
|
||||
textcolor(YELLOW);
|
||||
backcolor(BLACK);
|
||||
printf("press a key to show layer 0 and show the text!");
|
||||
while(!kbhit());
|
||||
clearline();
|
||||
|
||||
|
||||
// Now we activate layer 0.
|
||||
screenlayerenable(0);
|
||||
|
||||
// Wait for a keypress and after clear the line!
|
||||
textcolor(YELLOW);
|
||||
backcolor(BLACK);
|
||||
printf("press a key to hide layer 0 and hide the text again");
|
||||
while(!kbhit());
|
||||
clearline();
|
||||
|
||||
screenlayerdisable(0);
|
||||
|
||||
clrscr();
|
||||
textcolor(RED);
|
||||
backcolor(WHITE);
|
||||
gotoxy(19,10);
|
||||
printf(" ");
|
||||
gotoxy(19,11);
|
||||
printf(" analyze the code and learn! ");
|
||||
gotoxy(19,12);
|
||||
printf(" ");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user