mirror of
https://github.com/cc65/cc65.git
synced 2024-12-25 02:29:52 +00:00
simple conio support for GEOS
git-svn-id: svn://svn.cc65.org/cc65/trunk@1093 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
0fe03a4643
commit
8ce6c9bcac
@ -4,7 +4,7 @@
|
||||
#
|
||||
# Maciej 'YTM/Elysium' Witkowiak
|
||||
|
||||
OBJ_DIRS=common devel disk dlgbox file graph menuicon memory mousesprite process system
|
||||
OBJ_DIRS=common conio devel disk dlgbox file graph menuicon memory mousesprite process system
|
||||
|
||||
all:
|
||||
@for i in $(OBJ_DIRS); do $(MAKE) -C $$i; done
|
||||
|
16
libsrc/geos/conio/Makefile
Normal file
16
libsrc/geos/conio/Makefile
Normal file
@ -0,0 +1,16 @@
|
||||
#
|
||||
# Makefile for GEOS lib
|
||||
# for cc65
|
||||
#
|
||||
|
||||
%.o: %.s
|
||||
@$(AS) -o $@ $(AFLAGS) $<
|
||||
|
||||
|
||||
S_OBJS = cchvline.o cgetc.o clrscr.o color.o cputc.o cputs.o cursor.o gotoxy.o kbhit.o\
|
||||
revers.o screensize.o where.o
|
||||
|
||||
all: $(S_OBJS)
|
||||
|
||||
clean:
|
||||
@rm -f *.~ $(S_OBJS) core
|
29
libsrc/geos/conio/cchvline.s
Normal file
29
libsrc/geos/conio/cchvline.s
Normal file
@ -0,0 +1,29 @@
|
||||
|
||||
;
|
||||
; Maciej 'YTM/Elysium' Witkowiak
|
||||
;
|
||||
; 27.10.2001
|
||||
|
||||
; void cclearxy (unsigned char x, unsigned char y, unsigned char length);
|
||||
; void cclear (unsigned char length);
|
||||
; void chlinexy (unsigned char x, unsigned char y, unsigned char length);
|
||||
; void chline (unsigned char length);
|
||||
; void cvlinexy (unsigned char x, unsigned char y, unsigned char length);
|
||||
; void cvline (unsigned char length);
|
||||
|
||||
.export _cclearxy, _cclear
|
||||
.export _chlinexy, _chline
|
||||
.export _cvlinexy, _cvline
|
||||
.import popa
|
||||
|
||||
; unimplemented, will do nothing now
|
||||
|
||||
_cclearxy:
|
||||
_chlinexy:
|
||||
_cvlinexy:
|
||||
|
||||
jsr popa
|
||||
_cclear:
|
||||
_chline:
|
||||
_cvline:
|
||||
rts
|
43
libsrc/geos/conio/cgetc.s
Normal file
43
libsrc/geos/conio/cgetc.s
Normal file
@ -0,0 +1,43 @@
|
||||
|
||||
;
|
||||
; Maciej 'YTM/Elysium' Witkowiak
|
||||
;
|
||||
; 27.10.2001
|
||||
|
||||
; unsigned char cgetc (void);
|
||||
|
||||
.export _cgetc
|
||||
|
||||
.include "../inc/jumptab.inc"
|
||||
.include "../inc/geossym.inc"
|
||||
.include "cursor.inc"
|
||||
|
||||
_cgetc:
|
||||
; show cursor if needed
|
||||
lda cursor_flag
|
||||
beq L0
|
||||
|
||||
lda #1
|
||||
sta r3L
|
||||
lda cursor_x
|
||||
ldx cursor_x+1
|
||||
sta r4L
|
||||
sta stringX
|
||||
stx r4H
|
||||
stx stringX+1
|
||||
lda cursor_y
|
||||
sec
|
||||
sbc curHeight
|
||||
sta r5L
|
||||
sta stringY
|
||||
jsr PosSprite
|
||||
jsr PromptOn
|
||||
|
||||
L0: jsr GetNextChar
|
||||
tax
|
||||
beq L0
|
||||
pha
|
||||
jsr PromptOff
|
||||
pla
|
||||
ldx #0
|
||||
rts
|
35
libsrc/geos/conio/clrscr.s
Normal file
35
libsrc/geos/conio/clrscr.s
Normal file
@ -0,0 +1,35 @@
|
||||
|
||||
;
|
||||
; Maciej 'YTM/Elysium' Witkowiak
|
||||
;
|
||||
; 27.10.2001
|
||||
|
||||
; void clrscr (void);
|
||||
|
||||
.export _clrscr
|
||||
|
||||
.include "../inc/jumptab.inc"
|
||||
.include "../inc/geossym.inc"
|
||||
.include "../inc/const.inc"
|
||||
|
||||
_clrscr:
|
||||
lda #ST_WR_FORE | ST_WR_BACK
|
||||
sta dispBufferOn
|
||||
lda #0
|
||||
jsr SetPattern
|
||||
lda #0
|
||||
sta r3L
|
||||
sta r3H
|
||||
sta r2L
|
||||
lda #199
|
||||
sta r2H
|
||||
lda graphMode
|
||||
bpl L40
|
||||
lda #>639 ; 80 columns
|
||||
ldx #<639
|
||||
bne L99
|
||||
L40: lda #>319 ; 40 columns
|
||||
ldx #<319
|
||||
L99: sta r4H
|
||||
stx r4L
|
||||
jmp Rectangle
|
20
libsrc/geos/conio/color.s
Normal file
20
libsrc/geos/conio/color.s
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
;
|
||||
; Maciej 'YTM/Elysium' Witkowiak
|
||||
;
|
||||
; 27.10.2001
|
||||
|
||||
; unsigned char __fastcall__ textcolor (unsigned char color);
|
||||
; unsigned char __fastcall__ bgcolor (unsigned char color);
|
||||
; unsigned char __fastcall__ bordercolor (unsigned char color);
|
||||
;
|
||||
|
||||
|
||||
.export _textcolor, _bgcolor, _bordercolor
|
||||
|
||||
; for GEOS 2.0 there is no color support, perhaps Wheels has it
|
||||
|
||||
_textcolor:
|
||||
_bgcolor:
|
||||
_bordercolor:
|
||||
rts
|
76
libsrc/geos/conio/cputc.s
Normal file
76
libsrc/geos/conio/cputc.s
Normal file
@ -0,0 +1,76 @@
|
||||
|
||||
;
|
||||
; Maciej 'YTM/Elysium' Witkowiak
|
||||
;
|
||||
; 27.10.2001
|
||||
|
||||
; void cputcxy (unsigned char x, unsigned char y, char c);
|
||||
; void cputc (char c);
|
||||
|
||||
.export _cputcxy, _cputc, update_cursor
|
||||
|
||||
.import _gotoxy
|
||||
.import popa
|
||||
|
||||
.include "../inc/const.inc"
|
||||
.include "../inc/geossym.inc"
|
||||
.include "../inc/jumptab.inc"
|
||||
.include "cursor.inc"
|
||||
|
||||
_cputcxy:
|
||||
pha ; Save C
|
||||
jsr popa ; Get Y
|
||||
jsr _gotoxy ; Set cursor, drop x
|
||||
pla ; Restore C
|
||||
|
||||
; Plot a character - also used as internal function
|
||||
|
||||
_cputc:
|
||||
tax ; save character
|
||||
; some characters are not safe for PutChar
|
||||
cmp #$20
|
||||
bcs L1
|
||||
cmp #$1d
|
||||
bne L00
|
||||
ldx #BACKSPACE
|
||||
bne L1
|
||||
L00: cmp #ESC_GRAPHICS
|
||||
beq L0
|
||||
cmp #ESC_RULER
|
||||
beq L0
|
||||
cmp #GOTOX
|
||||
beq L0
|
||||
cmp #GOTOY
|
||||
beq L0
|
||||
cmp #GOTOXY
|
||||
beq L0
|
||||
cmp #NEWCARDSET
|
||||
beq L0
|
||||
cmp #$1e
|
||||
bne L1
|
||||
L0: rts
|
||||
|
||||
L1: lda cursor_x
|
||||
sta r11L
|
||||
lda cursor_x+1
|
||||
sta r11H
|
||||
lda cursor_y
|
||||
sta r1H
|
||||
txa
|
||||
jsr PutChar
|
||||
|
||||
update_cursor:
|
||||
lda r11L
|
||||
sta cursor_x
|
||||
sta r4L
|
||||
lda r11H
|
||||
sta cursor_x+1
|
||||
sta r4H
|
||||
lda r1H
|
||||
sta cursor_y
|
||||
sec
|
||||
sbc curHeight
|
||||
sta r5L
|
||||
lda #1 ; update cursor prompt position
|
||||
sta r3L
|
||||
jmp PosSprite
|
41
libsrc/geos/conio/cputs.s
Normal file
41
libsrc/geos/conio/cputs.s
Normal file
@ -0,0 +1,41 @@
|
||||
|
||||
;
|
||||
; Maciej 'YTM/Elysium' Witkowiak
|
||||
;
|
||||
; 27.10.2001
|
||||
|
||||
; void cputsxy (unsigned char x, unsigned char y, char* s);
|
||||
; void cputs (char* s);
|
||||
|
||||
.export _cputsxy, _cputs
|
||||
|
||||
.import update_cursor, _gotoxy
|
||||
.import popa
|
||||
|
||||
.include "../inc/const.inc"
|
||||
.include "../inc/geossym.inc"
|
||||
.include "../inc/jumptab.inc"
|
||||
.include "cursor.inc"
|
||||
|
||||
_cputsxy:
|
||||
sta r0L ; Save s for later
|
||||
stx r0H
|
||||
jsr popa ; Get Y
|
||||
jsr _gotoxy ; Set cursor, pop x
|
||||
jmp L0 ; Same as cputs...
|
||||
|
||||
_cputs: sta r0L ; Save s
|
||||
stx r0H
|
||||
L0: ldy #0
|
||||
lda (r0),y
|
||||
bne L1 ; Jump if there's something
|
||||
rts
|
||||
|
||||
L1: lda cursor_x
|
||||
sta r11L
|
||||
lda cursor_x+1
|
||||
sta r11H
|
||||
lda cursor_y
|
||||
sta r1H
|
||||
jsr PutString
|
||||
jmp update_cursor
|
11
libsrc/geos/conio/cursor.inc
Normal file
11
libsrc/geos/conio/cursor.inc
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
;
|
||||
; Maciej 'YTM/Elysium' Witkowiak
|
||||
;
|
||||
; 27.10.2001
|
||||
|
||||
SCREEN_PTR = $D1 ; Pointer to current char in text screen
|
||||
cursor_x = $D3 ; Cursor column (word)
|
||||
cursor_y = $D5 ; Cursor row
|
||||
cursor_flag = $D6 ; cursor on/off (0-off)
|
||||
|
35
libsrc/geos/conio/cursor.s
Normal file
35
libsrc/geos/conio/cursor.s
Normal file
@ -0,0 +1,35 @@
|
||||
|
||||
;
|
||||
; Maciej 'YTM/Elysium' Witkowiak
|
||||
;
|
||||
; 27.10.2001
|
||||
|
||||
; unsigned char cursor (unsigned char onoff);
|
||||
|
||||
.export _cursor
|
||||
.include "../inc/jumptab.inc"
|
||||
.include "../inc/geossym.inc"
|
||||
.include "cursor.inc"
|
||||
|
||||
_cursor:
|
||||
|
||||
tay ; onoff into Y
|
||||
ldx #0 ; High byte of result
|
||||
ldx cursor_flag ; Get old value
|
||||
sty cursor_flag ; Set new value
|
||||
tya
|
||||
beq L1
|
||||
lda curHeight ; prepare cursor
|
||||
jsr InitTextPrompt
|
||||
lda cursor_x ; position it on screen
|
||||
sta r4L
|
||||
lda cursor_x+1
|
||||
sta r4H
|
||||
lda cursor_y
|
||||
sec
|
||||
sbc curHeight
|
||||
sta r5L
|
||||
lda #1
|
||||
sta r3L
|
||||
jsr PosSprite
|
||||
L1: rts
|
35
libsrc/geos/conio/gotoxy.s
Normal file
35
libsrc/geos/conio/gotoxy.s
Normal file
@ -0,0 +1,35 @@
|
||||
|
||||
;
|
||||
; Maciej 'YTM/Elysium' Witkowiak
|
||||
;
|
||||
; 27.10.2001
|
||||
|
||||
; void gotox (unsigned char x);
|
||||
; void gotoy (unsigned char y);
|
||||
; void gotoxy (unsigned char x, unsigned char y);
|
||||
|
||||
.export _gotox, _gotoy, _gotoxy
|
||||
.import popa
|
||||
|
||||
.include "../inc/jumptab.inc"
|
||||
.include "cursor.inc"
|
||||
|
||||
_gotox: sta cursor_x
|
||||
jmp fixcursor
|
||||
|
||||
_gotoy: sta cursor_y
|
||||
jmp fixcursor
|
||||
|
||||
_gotoxy: sta cursor_y
|
||||
jsr popa
|
||||
sta cursor_x
|
||||
|
||||
; convert 8x8 x/y coordinates to GEOS hires
|
||||
fixcursor:
|
||||
ldx #cursor_x
|
||||
ldy #3
|
||||
jsr DShiftLeft
|
||||
asl cursor_y
|
||||
asl cursor_y
|
||||
asl cursor_y
|
||||
rts
|
19
libsrc/geos/conio/kbhit.s
Normal file
19
libsrc/geos/conio/kbhit.s
Normal file
@ -0,0 +1,19 @@
|
||||
|
||||
;
|
||||
; Maciej 'YTM/Elysium' Witkowiak
|
||||
;
|
||||
; 27.10.2001
|
||||
|
||||
; unsigned char kbhit (void);
|
||||
|
||||
.export _kbhit
|
||||
.import return0, return1
|
||||
|
||||
.include "../inc/jumptab.inc"
|
||||
.include "../inc/geossym.inc"
|
||||
|
||||
_kbhit:
|
||||
lda pressFlag
|
||||
bmi L1
|
||||
jmp return0
|
||||
L1: jmp return1
|
36
libsrc/geos/conio/revers.s
Normal file
36
libsrc/geos/conio/revers.s
Normal file
@ -0,0 +1,36 @@
|
||||
|
||||
;
|
||||
; Maciej 'YTM/Elysium' Witkowiak
|
||||
;
|
||||
; 27.10.2001
|
||||
|
||||
; unsigned char revers (unsigned char onoff);
|
||||
|
||||
.export _revers
|
||||
.import tmp1
|
||||
|
||||
.include "../inc/geossym.inc"
|
||||
.include "../inc/const.inc"
|
||||
|
||||
_revers:
|
||||
tax
|
||||
bne L0 ; turn on
|
||||
lda #0
|
||||
.byte $2c
|
||||
L0: lda #SET_REVERSE
|
||||
sta tmp1
|
||||
|
||||
lda currentMode
|
||||
tax
|
||||
and #SET_REVERSE
|
||||
tay ; store old value
|
||||
txa
|
||||
and #%11011111 ; mask out
|
||||
ora tmp1 ; set new value
|
||||
sta currentMode
|
||||
|
||||
ldx #0
|
||||
tya
|
||||
beq L1
|
||||
lda #1
|
||||
L1: rts
|
35
libsrc/geos/conio/screensize.s
Normal file
35
libsrc/geos/conio/screensize.s
Normal file
@ -0,0 +1,35 @@
|
||||
|
||||
;
|
||||
; Maciej 'YTM/Elysium' Witkowiak
|
||||
;
|
||||
; 27.10.2001
|
||||
|
||||
; void screensize (unsigned char* x, unsigned char* y);
|
||||
;
|
||||
|
||||
.export _screensize
|
||||
|
||||
.import popax
|
||||
.importzp ptr1, ptr2
|
||||
|
||||
.include "../inc/geossym.inc"
|
||||
|
||||
_screensize:
|
||||
|
||||
sta ptr1 ; Store the y pointer
|
||||
stx ptr1+1
|
||||
|
||||
jsr popax ; get the x pointer
|
||||
sta ptr2
|
||||
stx ptr2+1
|
||||
|
||||
ldy #0
|
||||
lda graphMode
|
||||
bpl L1
|
||||
lda #80 ; 80 columns (more or less)
|
||||
.byte $2c
|
||||
L1: lda #40 ; 40 columns (more or less)
|
||||
sta (ptr2),y
|
||||
lda #24 ; something like that for Y size
|
||||
sta (ptr1),y
|
||||
rts
|
30
libsrc/geos/conio/where.s
Normal file
30
libsrc/geos/conio/where.s
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
;
|
||||
; Maciej 'YTM/Elysium' Witkowiak
|
||||
;
|
||||
; 27.10.2001
|
||||
|
||||
; unsigned char wherex (void);
|
||||
; unsigned char wherey (void);
|
||||
|
||||
.export _wherex, _wherey
|
||||
.importzp tmp1, tmp2
|
||||
|
||||
.include "../inc/jumptab.inc"
|
||||
.include "cursor.inc"
|
||||
|
||||
_wherex: lda cursor_x
|
||||
sta tmp1
|
||||
lda cursor_x+1
|
||||
sta tmp2
|
||||
lda #tmp1
|
||||
ldy #3
|
||||
jsr DShiftRight
|
||||
lda tmp1
|
||||
rts
|
||||
|
||||
_wherey: lda cursor_y
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
rts
|
34
samples/geos/geosconio.c
Normal file
34
samples/geos/geosconio.c
Normal file
@ -0,0 +1,34 @@
|
||||
|
||||
#include <geos.h>
|
||||
#include <conio.h>
|
||||
|
||||
void main(void) {
|
||||
|
||||
char ch;
|
||||
|
||||
DlgBoxOk("Now the screen will be", "cleared.");
|
||||
|
||||
clrscr();
|
||||
|
||||
DlgBoxOk("Now a character will be", "written at 20,20");
|
||||
|
||||
gotoxy(20,20);
|
||||
cputc('A');
|
||||
|
||||
DlgBoxOk("Now a string will be", "written at 0,1");
|
||||
|
||||
cputsxy(0,1, CBOLDON "Just" COUTLINEON "a " CITALICON "string." CPLAINTEXT );
|
||||
|
||||
DlgBoxOk("Write text and finish it", "with a dot.");
|
||||
|
||||
cursor(1);
|
||||
do {
|
||||
ch = cgetc();
|
||||
cputc(ch);
|
||||
} while (ch!='.');
|
||||
|
||||
DlgBoxOk("Seems that it is all.", "Bye.");
|
||||
|
||||
EnterDeskTop();
|
||||
|
||||
}
|
8
samples/geos/geosconiores.res
Normal file
8
samples/geos/geosconiores.res
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
; this is resource file for hello1.c, a GEOS application example
|
||||
|
||||
HEADER APPLICATION "conio" "ConIO" "V0.1" {
|
||||
dostype USR
|
||||
author "Maciej Witkowiak"
|
||||
info "This is an example for a conio app."
|
||||
}
|
Loading…
Reference in New Issue
Block a user