From: izydorst Date: Sat, 27 Oct 2001 17:13:22 +0000 (+0000) Subject: simple conio support for GEOS X-Git-Tag: V2.12.0~2509 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=8ce6c9bcac6a2710f66233a1485576fd7ca31cfd;p=cc65 simple conio support for GEOS git-svn-id: svn://svn.cc65.org/cc65/trunk@1093 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/libsrc/geos/Makefile b/libsrc/geos/Makefile index c38db30e4..25d908534 100644 --- a/libsrc/geos/Makefile +++ b/libsrc/geos/Makefile @@ -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 diff --git a/libsrc/geos/conio/Makefile b/libsrc/geos/conio/Makefile new file mode 100644 index 000000000..6d3abd9ab --- /dev/null +++ b/libsrc/geos/conio/Makefile @@ -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 diff --git a/libsrc/geos/conio/cchvline.s b/libsrc/geos/conio/cchvline.s new file mode 100644 index 000000000..3d32196c9 --- /dev/null +++ b/libsrc/geos/conio/cchvline.s @@ -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 diff --git a/libsrc/geos/conio/cgetc.s b/libsrc/geos/conio/cgetc.s new file mode 100644 index 000000000..8212675bc --- /dev/null +++ b/libsrc/geos/conio/cgetc.s @@ -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 diff --git a/libsrc/geos/conio/clrscr.s b/libsrc/geos/conio/clrscr.s new file mode 100644 index 000000000..444823a89 --- /dev/null +++ b/libsrc/geos/conio/clrscr.s @@ -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 diff --git a/libsrc/geos/conio/color.s b/libsrc/geos/conio/color.s new file mode 100644 index 000000000..e5498041e --- /dev/null +++ b/libsrc/geos/conio/color.s @@ -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 diff --git a/libsrc/geos/conio/cputc.s b/libsrc/geos/conio/cputc.s new file mode 100644 index 000000000..4120abf70 --- /dev/null +++ b/libsrc/geos/conio/cputc.s @@ -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 diff --git a/libsrc/geos/conio/cputs.s b/libsrc/geos/conio/cputs.s new file mode 100644 index 000000000..2f5276ac6 --- /dev/null +++ b/libsrc/geos/conio/cputs.s @@ -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 diff --git a/libsrc/geos/conio/cursor.inc b/libsrc/geos/conio/cursor.inc new file mode 100644 index 000000000..88c61a835 --- /dev/null +++ b/libsrc/geos/conio/cursor.inc @@ -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) + diff --git a/libsrc/geos/conio/cursor.s b/libsrc/geos/conio/cursor.s new file mode 100644 index 000000000..d2ec60579 --- /dev/null +++ b/libsrc/geos/conio/cursor.s @@ -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 diff --git a/libsrc/geos/conio/gotoxy.s b/libsrc/geos/conio/gotoxy.s new file mode 100644 index 000000000..58ba858d4 --- /dev/null +++ b/libsrc/geos/conio/gotoxy.s @@ -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 diff --git a/libsrc/geos/conio/kbhit.s b/libsrc/geos/conio/kbhit.s new file mode 100644 index 000000000..4f065cdfe --- /dev/null +++ b/libsrc/geos/conio/kbhit.s @@ -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 diff --git a/libsrc/geos/conio/revers.s b/libsrc/geos/conio/revers.s new file mode 100644 index 000000000..b2d208838 --- /dev/null +++ b/libsrc/geos/conio/revers.s @@ -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 diff --git a/libsrc/geos/conio/screensize.s b/libsrc/geos/conio/screensize.s new file mode 100644 index 000000000..c04fc92ae --- /dev/null +++ b/libsrc/geos/conio/screensize.s @@ -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 diff --git a/libsrc/geos/conio/where.s b/libsrc/geos/conio/where.s new file mode 100644 index 000000000..3c5767954 --- /dev/null +++ b/libsrc/geos/conio/where.s @@ -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 diff --git a/samples/geos/geosconio.c b/samples/geos/geosconio.c new file mode 100644 index 000000000..6e116f792 --- /dev/null +++ b/samples/geos/geosconio.c @@ -0,0 +1,34 @@ + +#include +#include + +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(); + +} diff --git a/samples/geos/geosconiores.res b/samples/geos/geosconiores.res new file mode 100644 index 000000000..9f2c0bbdb --- /dev/null +++ b/samples/geos/geosconiores.res @@ -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." +}