mirror of
https://github.com/cc65/cc65.git
synced 2024-12-22 12:30:41 +00:00
Add KIM-1 functions to write to the 7-segment LED display and get
keypresses from the keypad. Includes sample program illustrating how to use them. Tested on real KIM-1 hardware.
This commit is contained in:
parent
d69117c0c1
commit
3a5fbd34da
@ -16,6 +16,10 @@ INTCHR := $1E5A ; Input character without case conversion
|
||||
DUMPT := $1800 ; Dump memory to tape
|
||||
LOADT := $1873 ; Load memory from tape
|
||||
START := $1C4F ; Enter KIM-1 monitor
|
||||
SCANDS := $1F1F ; Scan 7-segment display
|
||||
KEYIN := $1F40 ; Open up keyboard channel
|
||||
GETKEY := $1F6A ; Return key from keyboard
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; System Memory
|
||||
|
@ -56,5 +56,18 @@ int __fastcall__ loadt (unsigned char);
|
||||
/* Write to tape */
|
||||
int __fastcall__ dumpt (unsigned char, const void*, const void*);
|
||||
|
||||
|
||||
/* Write to 7-segment LED display. Due to hardware limitations it only
|
||||
** displays briefly, so must be called repeatedly to update the
|
||||
** display.
|
||||
**/
|
||||
void __fastcall__ scandisplay(unsigned char left, unsigned char middle, unsigned char right);
|
||||
|
||||
/*
|
||||
** Get a keypress from the keypad. Returns $00-$0F(0-F), $10(AD), $11(DA), $12(+),
|
||||
** $13(GO), $14(PC) or $15 for no keypress.
|
||||
**/
|
||||
int __fastcall__ getkey();
|
||||
|
||||
/* End of sym1.h */
|
||||
#endif
|
||||
|
18
libsrc/kim1/getkey.s
Normal file
18
libsrc/kim1/getkey.s
Normal file
@ -0,0 +1,18 @@
|
||||
;
|
||||
; int __fastcall__ getkey();
|
||||
;
|
||||
|
||||
.include "kim1.inc"
|
||||
|
||||
.import popa
|
||||
|
||||
.export _getkey
|
||||
|
||||
.proc _getkey
|
||||
|
||||
jsr KEYIN ; Open up keyboard channel
|
||||
jsr GETKEY ; Get key code
|
||||
ldx #0 ; MSB of return value is zero
|
||||
rts
|
||||
|
||||
.endproc
|
21
libsrc/kim1/scandisplay.s
Normal file
21
libsrc/kim1/scandisplay.s
Normal file
@ -0,0 +1,21 @@
|
||||
;
|
||||
; void __fastcall__ scandisplay(unsigned char left, unsigned char middle, unsigned char right);
|
||||
;
|
||||
|
||||
.include "kim1.inc"
|
||||
|
||||
.import popa
|
||||
|
||||
.export _scandisplay
|
||||
|
||||
.proc _scandisplay
|
||||
|
||||
sta $F9 ; Rightmost display data
|
||||
jsr popa
|
||||
sta $FA ; Middle display data
|
||||
jsr popa
|
||||
sta $FB ; Leftmost display data
|
||||
jsr SCANDS
|
||||
rts
|
||||
|
||||
.endproc
|
52
samples/kim1/kimKeyDisp.c
Normal file
52
samples/kim1/kimKeyDisp.c
Normal file
@ -0,0 +1,52 @@
|
||||
/* Example illustrating scandisplay() and getkey() functions. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <kim1.h>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
int i, j, k, l;
|
||||
int last = 15;
|
||||
|
||||
printf("\nKIM-1 Demo\n");
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
for (j = 0; j < 16; j++) {
|
||||
for (k = 0; k < 16; k++) {
|
||||
scandisplay(i, j, k);
|
||||
|
||||
l = getkey();
|
||||
|
||||
if (l != last) {
|
||||
switch (l) {
|
||||
case 0x0: case 0x1: case 0x2: case 0x3:
|
||||
case 0x4: case 0x5: case 0x6: case 0x7:
|
||||
case 0x8: case 0x9: case 0xa: case 0xb:
|
||||
case 0xc: case 0xd: case 0xe: case 0xf:
|
||||
printf("Key pressed: %X\n", l);
|
||||
break;
|
||||
case 0x10:
|
||||
printf("Key pressed: AD\n");
|
||||
break;
|
||||
case 0x11:
|
||||
printf("Key pressed: DA\n");
|
||||
break;
|
||||
case 0x12:
|
||||
printf("Key pressed: +\n");
|
||||
break;
|
||||
case 0x13:
|
||||
printf("Key pressed: GO\n");
|
||||
break;
|
||||
case 0x14:
|
||||
printf("Key pressed: PC\n");
|
||||
break;
|
||||
}
|
||||
|
||||
last = l;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user