]> git.sur5r.net Git - cc65/commitdiff
Add basic support for ORIC Atmos
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sun, 13 Apr 2003 22:12:09 +0000 (22:12 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sun, 13 Apr 2003 22:12:09 +0000 (22:12 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@2046 b7a2c559-68d2-44c3-8de9-860c34a00d81

21 files changed:
libsrc/atmos/Makefile
libsrc/atmos/_scrsize.s [new file with mode: 0644]
libsrc/atmos/atmos.inc [new file with mode: 0644]
libsrc/atmos/cclear.s [new file with mode: 0644]
libsrc/atmos/cgetc.s [new file with mode: 0644]
libsrc/atmos/chline.s [new file with mode: 0644]
libsrc/atmos/clock.s [new file with mode: 0644]
libsrc/atmos/clrscr.s [new file with mode: 0644]
libsrc/atmos/color.s [new file with mode: 0644]
libsrc/atmos/cputc.s [new file with mode: 0644]
libsrc/atmos/crt0.s
libsrc/atmos/ctype.s [new file with mode: 0644]
libsrc/atmos/cvline.s [new file with mode: 0644]
libsrc/atmos/gotox.s [new file with mode: 0644]
libsrc/atmos/gotoxy.s [new file with mode: 0644]
libsrc/atmos/gotoy.s [new file with mode: 0644]
libsrc/atmos/kbhit.s [new file with mode: 0644]
libsrc/atmos/revers.s [new file with mode: 0644]
libsrc/atmos/wherex.s [new file with mode: 0644]
libsrc/atmos/wherey.s [new file with mode: 0644]
libsrc/atmos/write.s [new file with mode: 0644]

index 7a07b6c52fc43e51d148cde843a18eca20fbbb5e..3b9bd42e6ba3e571a1d2aa6071b5fafc0e44c773 100644 (file)
 
 C_OBJS =
 
-S_OBJS  =       crt0.o          \
+S_OBJS  =       _scrsize.o      \
+                cclear.o        \
+                cgetc.o         \
+                chline.o        \
+                clock.o         \
+                clrscr.o        \
+                color.o         \
+                cputc.o         \
+                crt0.o          \
+                ctype.o         \
+                cvline.o        \
+                gotox.o         \
+                gotoxy.o        \
+                gotoy.o         \
+                kbhit.o         \
                 mainargs.o      \
-                systime.o
+                revers.o        \
+                systime.o       \
+                wherex.o        \
+                wherey.o        \
+                write.o         
 
 #--------------------------------------------------------------------------
 # Targets
diff --git a/libsrc/atmos/_scrsize.s b/libsrc/atmos/_scrsize.s
new file mode 100644 (file)
index 0000000..24eec24
--- /dev/null
@@ -0,0 +1,17 @@
+;
+; Ullrich von Bassewitz, 2003-04-13
+;
+; Screen size variables
+;
+
+       .export         screensize
+
+.proc   screensize
+
+        ldx     #40
+        ldy     #28
+        rts
+
+.endproc
+
+
diff --git a/libsrc/atmos/atmos.inc b/libsrc/atmos/atmos.inc
new file mode 100644 (file)
index 0000000..c144a7d
--- /dev/null
@@ -0,0 +1,30 @@
+;
+; Oric atmos zeropage and ROM definitions
+;
+
+
+; ---------------------------------------------------------------------------
+; Zero page
+
+
+
+; ---------------------------------------------------------------------------
+; Low memory
+
+CURS_Y          = $268
+CURS_X          = $269
+STATUS          = $26A
+TIMER3          = $276
+KEYBUF          = $2DF
+
+
+; ---------------------------------------------------------------------------
+; ROM entries
+                      
+PRINT           = $F77C
+
+
+; ---------------------------------------------------------------------------
+; I/O
+
+SCREEN          = $BB80
diff --git a/libsrc/atmos/cclear.s b/libsrc/atmos/cclear.s
new file mode 100644 (file)
index 0000000..1076967
--- /dev/null
@@ -0,0 +1,38 @@
+;
+; Ullrich von Bassewitz, 2003-04-13
+;
+; void cclearxy (unsigned char x, unsigned char y, unsigned char length);
+; void cclear (unsigned char length);
+;
+
+       .export         _cclearxy, _cclear
+        .import         setscrptr  
+        .import         rvs
+       .import         popax
+        .importzp       ptr2
+
+        .include        "atmos.inc"
+
+
+_cclearxy:
+               pha                     ; Save the length
+       jsr     popax           ; Get X and Y
+        sta     CURS_Y          ; Store Y
+        stx     CURS_X          ; Store X
+               pla                     ; Restore the length and run into _cclear
+
+_cclear:
+               tax                     ; Is the length zero?
+               beq     @L9             ; Jump if done
+        jsr     setscrptr       ; Set ptr2 to screen, won't use X
+        lda     #' '       
+        ora     rvs
+@L1:    sta     (ptr2),y        ; Write one char
+        iny                     ; Next char
+        bne     @L2
+        inc     ptr2+1          ; Bump high byte of screen pointer
+@L2:    dex
+        bne     @L1
+@L9:   rts
+
+
diff --git a/libsrc/atmos/cgetc.s b/libsrc/atmos/cgetc.s
new file mode 100644 (file)
index 0000000..b927af6
--- /dev/null
@@ -0,0 +1,67 @@
+;
+; Ullrich von Bassewitz, 2003-04-13
+;
+; char cgetc (void);
+;
+
+       .export         _cgetc
+        .constructor    cursoroff
+        .destructor     cursoron
+       .import         cursor
+
+       .include        "atmos.inc"
+
+
+
+; ------------------------------------------------------------------------
+;
+
+.proc   _cgetc
+
+        lda     KEYBUF          ; Do we have a character?
+        bmi     @L2             ; Yes: Get it
+
+; No character, enable cursor and wait
+
+        lda     cursor          ; Cursor currently off?
+        beq     @L1             ; Skip if so
+        jsr     cursoron
+@L1:    lda     KEYBUF
+        bpl     @L1
+
+; If the cursor was enabled, disable it now
+
+        ldx     cursor
+        beq     @L3
+        dec     STATUS          ; Clear bit zero
+
+; We have the character, clear avail flag
+
+@L2:    and     #$7F            ; Mask out avail flag
+        sta     KEYBUF
+
+; Done
+
+@L3:    ldx     #$00
+        rts
+
+.endproc
+
+; ------------------------------------------------------------------------
+; Switch the cursor on
+
+cursoron:
+        lda     STATUS
+        ora     #%00000001
+        sta     STATUS
+        rts
+
+; ------------------------------------------------------------------------
+; Switch the cursor off
+
+cursoroff:
+        lda     STATUS
+        and     #%11111110
+        sta     STATUS
+        rts
+
diff --git a/libsrc/atmos/chline.s b/libsrc/atmos/chline.s
new file mode 100644 (file)
index 0000000..85c7b58
--- /dev/null
@@ -0,0 +1,41 @@
+;
+; Ullrich von Bassewitz, 08.08.1998
+;
+; void chlinexy (unsigned char x, unsigned char y, unsigned char length);
+; void chline (unsigned char length);
+;
+
+       .export         _chlinexy, _chline
+        .import         setscrptr
+        .import         rvs
+       .import         popax
+        .importzp       ptr2
+
+        .include        "atmos.inc"
+
+
+_chlinexy:
+               pha                     ; Save the length
+       jsr     popax           ; Get X and Y
+        sta     CURS_Y          ; Store Y
+        stx     CURS_X          ; Store X
+               pla                     ; Restore the length and run into _chline
+
+_chline:
+               tax                     ; Is the length zero?
+               beq     @L9             ; Jump if done
+        jsr     setscrptr       ; Set ptr2 to screen, won't use X
+        txa                     ; Length into A
+        clc
+        adc     CURS_X
+        sta     CURS_X          ; Correct X position by length
+        lda     #'-'            ; Horizontal line screen code
+        ora     rvs
+@L1:    sta     (ptr2),y        ; Write one char
+        iny                     ; Next char
+        bne     @L2
+        inc     ptr2+1          ; Bump high byte of screen pointer
+@L2:    dex
+        bne     @L1
+@L9:   rts
+
diff --git a/libsrc/atmos/clock.s b/libsrc/atmos/clock.s
new file mode 100644 (file)
index 0000000..56573a5
--- /dev/null
@@ -0,0 +1,36 @@
+;
+; Ullrich von Bassewitz, 2003-04-13
+;
+; clock_t clock (void);
+;
+
+       .export         _clock
+        .import         negax
+       .importzp       sreg
+
+       .include        "atmos.inc"
+
+
+.proc  _clock
+
+; Clear the timer high 16 bits
+
+        ldy     #$00
+        sty     sreg
+        sty     sreg+1
+
+; Read the timer
+
+        sei                     ; Disable interrupts
+        lda     TIMER3
+        ldx     TIMER3+1
+        cli                     ; Reenable interrupts
+
+
+; Since the timer is counting downwards, return the negated value
+
+        jmp     negax
+
+.endproc
+
+
diff --git a/libsrc/atmos/clrscr.s b/libsrc/atmos/clrscr.s
new file mode 100644 (file)
index 0000000..7402356
--- /dev/null
@@ -0,0 +1,47 @@
+;
+; Ullrich von Bassewitz, 2003-04-13
+;
+
+       .export         _clrscr
+        .importzp       ptr2
+
+       .include        "atmos.inc"
+
+; ------------------------------------------------------------------------
+; void __fastcall__ clrscr (void);
+
+.proc  _clrscr
+
+; Set the cursor to top left cursor position
+
+        ldy     #$00
+        sty     CURS_X
+        sty     CURS_Y
+
+; Set ptr2 to the screen position (left upper border)
+
+        lda     #<SCREEN
+        sta     ptr2
+        lda     #>SCREEN
+        sta     ptr2+1
+
+; Clear full pages. Y is still zero
+
+        ldx     #>(28*40)
+        lda     #' '
+@L1:    sta     (ptr2),y
+        iny                     ; Bump low byte of address
+        bne     @L1
+        inc     ptr2+1          ; Bump high byte of address
+        dex
+        bne     @L1
+
+; Clear the remaining page
+
+@L2:    sta     (ptr2),y
+        iny
+        cpy     #<(28*40)
+        bne     @L2
+        rts
+
+.endproc
diff --git a/libsrc/atmos/color.s b/libsrc/atmos/color.s
new file mode 100644 (file)
index 0000000..3a73ee5
--- /dev/null
@@ -0,0 +1,18 @@
+;
+; Ullrich von Bassewitz, 2003-04-13
+;
+; 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
+        .import         return0, return1
+
+_textcolor     = return1
+
+_bgcolor       = return0
+
+_bordercolor   = return0
+
+
diff --git a/libsrc/atmos/cputc.s b/libsrc/atmos/cputc.s
new file mode 100644 (file)
index 0000000..6d4f17b
--- /dev/null
@@ -0,0 +1,96 @@
+;
+; Ullrich von Bassewitz, 2003-04-13
+;
+; void cputcxy (unsigned char x, unsigned char y, char c);
+; void cputc (char c);
+;
+
+       .export         _cputcxy, _cputc
+       .export         setscrptr, putchar
+        .import         rvs
+       .import         popax
+        .importzp       ptr2
+
+       .include        "atmos.inc"
+
+
+_cputcxy:
+       pha                     ; Save C
+       jsr     popax           ; Get X and Y
+        sta     CURS_Y          ; Store Y
+        stx     CURS_X          ; Store X
+       pla                     ; Restore C
+
+; Plot a character - also used as internal function
+
+_cputc: cmp            #$0D            ; CR?
+       bne     L1
+       lda     #0
+       sta     CURS_X          ; Carriage return
+        rts
+
+L1:    cmp     #$0A            ; LF?
+               bne     output
+        inc    CURS_Y          ; Newline
+       rts
+
+; Output the character, then advance the cursor position
+
+output:
+        jsr     putchar
+
+advance:
+       iny
+       cpy     #40
+       bne     L3
+               inc     CURS_Y          ; new line
+       ldy     #0              ; + cr
+L3:    sty     CURS_X
+       rts
+
+; ------------------------------------------------------------------------
+; Set ptr2 to the screen, load the X offset into Y
+
+.code
+.proc   setscrptr
+
+        ldy     CURS_Y          ; Get line number into Y
+        lda     ScrTabLo,y      ; Get low byte of line address
+        sta     ptr2
+        lda     ScrTabHi,y      ; Get high byte of line address
+        sta     ptr2+1
+               ldy     CURS_X          ; Get X offset
+        rts
+
+.endproc
+
+; ------------------------------------------------------------------------
+; Write one character to the screen without doing anything else, return X
+; position in Y
+
+.code
+.proc   putchar
+
+               ora     rvs             ; Set revers bit
+        pha                     ; And save
+        jsr     setscrptr       ; Set ptr2 to the screen
+        pla                     ; Restore the character
+               sta     (ptr2),y        ; Set char
+               rts
+
+.endproc
+
+; ------------------------------------------------------------------------
+; Screen address table
+
+.rodata
+ScrTabLo:
+        .repeat 28, Line
+                .byte   <(SCREEN + Line * 40)
+        .endrep
+
+ScrTabHi:
+        .repeat 28, Line
+                .byte   >(SCREEN + Line * 40)
+        .endrep
+
index cb1b5a14eabd6a45ddf9638f4583fad8e0f9de33..447f26101b0b6d611f022ae634a89f7f8c9b3e5e 100644 (file)
@@ -8,25 +8,59 @@
 
        .export         _exit
        .import         initlib, donelib
-       .import         push0, callmain, zerobss
-       .import         __RAM_START__, __RAM_SIZE__     ; Linker generated
+       .import         callmain, zerobss
+               .import         __RAM_START__, __RAM_SIZE__, __RAM_LAST__
+
+        .include        "zeropage.inc"
+        .include        "atmos.inc"
 
-        .importzp       sp
 
 ; ------------------------------------------------------------------------
 ; Create an empty LOWCODE segment to avoid linker warnings
 
 .segment        "LOWCODE"
 
+; ------------------------------------------------------------------------
+; Oric tape header
+
+.segment        "TAPEHDR"
+
+        .byte   $16, $16, $16   ; Sync bytes
+        .byte   $24             ; End of header marker
+
+        .byte   $00                             ; $2B0
+        .byte   $00                             ; $2AF
+        .byte   $80                             ; $2AE Machine code flag
+        .byte   $C7                             ; $2AD Autoload flag
+        .dbyt   __RAM_START__ + __RAM_LAST__    ; $2AB
+        .dbyt   __RAM_START__                   ; $2A9
+        .byte   $00                             ; $2A8
+        .byte   $00                             ; Zero terminated name
+
 ; ------------------------------------------------------------------------
 ; Place the startup code in a special segment.
 
 .segment               "STARTUP"
 
+; Save the zero page area we're about to use
+
+       ldx     #zpspace-1
+L1:    lda     sp,x
+       sta     zpsave,x        ; Save the zero page locations we need
+       dex
+               bpl     L1
+
 ; Clear the BSS data
 
        jsr     zerobss
 
+; Unprotect columns 0 and 1
+
+        lda     STATUS
+        sta     stsave
+        and     #%11011111
+        sta     STATUS
+
 ; Save system stuff and setup the stack
 
                tsx
@@ -53,6 +87,16 @@ _exit:       jsr     donelib         ; Run module destructors
 
        ldx     spsave
        txs
+        lda     stsave
+        sta     STATUS
+
+; Copy back the zero page stuff
+
+               ldx     #zpspace-1
+L2:    lda     zpsave,x
+       sta     sp,x
+       dex
+               bpl     L2
 
 ; Back to BASIC
 
@@ -61,7 +105,12 @@ _exit:      jsr     donelib         ; Run module destructors
 ; ------------------------------------------------------------------------
 ; Data
 
+.data
+
+zpsave:        .res    zpspace
+
 .bss
 spsave:        .res    1
+stsave: .res    1
 
 
diff --git a/libsrc/atmos/ctype.s b/libsrc/atmos/ctype.s
new file mode 100644 (file)
index 0000000..15b7ea9
--- /dev/null
@@ -0,0 +1,299 @@
+;
+; Ullrich von Bassewitz, 2003-04-13
+;
+; Character specification table.
+;
+
+; The tables are readonly, put them into the rodata segment
+
+.rodata
+
+; The following 256 byte wide table specifies attributes for the isxxx type
+; of functions. Doing it by a table means some overhead in space, but it
+; has major advantages:
+;
+;   * It is fast. If it were'nt for the slow parameter passing of cc65, one
+;     could even define macros for the isxxx functions (this is usually
+;     done on other platforms).
+;
+;   * It is highly portable. The only unportable part is the table itself,
+;     all real code goes into the common library.
+;
+;   * We save some code in the isxxx functions.
+;
+;
+; Bit assignments:
+;
+;   0 - Lower case char
+;   1 - Upper case char
+;   2 - Numeric digit
+;   3 - Hex digit (both, lower and upper)
+;   4 - Control character
+;   5 - The space character itself
+;   6 - Other whitespace (that is: '\f', '\n', '\r', '\t' and '\v')
+;   7 - Space or tab character
+
+       .export         __ctype
+
+__ctype:
+               .byte   $10     ;   0/00 ___ctrl_@___
+               .byte   $10     ;   1/01 ___ctrl_A___
+               .byte   $10     ;   2/02 ___ctrl_B___
+               .byte   $10     ;   3/03 ___ctrl_C___
+               .byte   $10     ;   4/04 ___ctrl_D___
+               .byte   $10     ;   5/05 ___ctrl_E___
+               .byte   $10     ;   6/06 ___ctrl_F___
+               .byte   $10     ;   7/07 ___ctrl_G___
+               .byte   $10     ;   8/08 ___ctrl_H___
+               .byte   $D0     ;   9/09 ___ctrl_I___
+               .byte   $50     ;  10/0a ___ctrl_J___
+               .byte   $50     ;  11/0b ___ctrl_K___
+               .byte   $50     ;  12/0c ___ctrl_L___
+               .byte   $50     ;  13/0d ___ctrl_M___
+               .byte   $10     ;  14/0e ___ctrl_N___
+               .byte   $10     ;  15/0f ___ctrl_O___
+               .byte   $10     ;  16/10 ___ctrl_P___
+               .byte   $10     ;  17/11 ___ctrl_Q___
+               .byte   $10     ;  18/12 ___ctrl_R___
+               .byte   $10     ;  19/13 ___ctrl_S___
+               .byte   $10     ;  20/14 ___ctrl_T___
+               .byte   $10     ;  21/15 ___ctrl_U___
+               .byte   $10     ;  22/16 ___ctrl_V___
+               .byte   $10     ;  23/17 ___ctrl_W___
+               .byte   $10     ;  24/18 ___ctrl_X___
+               .byte   $10     ;  25/19 ___ctrl_Y___
+               .byte   $10     ;  26/1a ___ctrl_Z___
+               .byte   $10     ;  27/1b ___ctrl_[___
+               .byte   $10     ;  28/1c ___ctrl_\___
+               .byte   $10     ;  29/1d ___ctrl_]___
+               .byte   $10     ;  30/1e ___ctrl_^___
+               .byte   $10     ;  31/1f ___ctrl_____
+               .byte   $A0     ;  32/20 ___SPACE___
+       .byte   $00     ;  33/21 _____!_____
+       .byte   $00     ;  34/22 _____"_____
+       .byte   $00     ;  35/23 _____#_____
+       .byte   $00     ;  36/24 _____$_____
+       .byte   $00     ;  37/25 _____%_____
+       .byte   $00     ;  38/26 _____&_____
+       .byte   $00     ;  39/27 _____'_____
+       .byte   $00     ;  40/28 _____(_____
+       .byte   $00     ;  41/29 _____)_____
+       .byte   $00     ;  42/2a _____*_____
+       .byte   $00     ;  43/2b _____+_____
+       .byte   $00     ;  44/2c _____,_____
+       .byte   $00     ;  45/2d _____-_____
+       .byte   $00     ;  46/2e _____._____
+       .byte   $00     ;  47/2f _____/_____
+       .byte   $0C     ;  48/30 _____0_____
+       .byte   $0C     ;  49/31 _____1_____
+       .byte   $0C     ;  50/32 _____2_____
+       .byte   $0C     ;  51/33 _____3_____
+       .byte   $0C     ;  52/34 _____4_____
+       .byte   $0C     ;  53/35 _____5_____
+       .byte   $0C     ;  54/36 _____6_____
+       .byte   $0C     ;  55/37 _____7_____
+       .byte   $0C     ;  56/38 _____8_____
+       .byte   $0C     ;  57/39 _____9_____
+       .byte   $00     ;  58/3a _____:_____
+       .byte   $00     ;  59/3b _____;_____
+       .byte   $00     ;  60/3c _____<_____
+       .byte   $00     ;  61/3d _____=_____
+       .byte   $00     ;  62/3e _____>_____
+       .byte   $00     ;  63/3f _____?_____
+
+       .byte   $00     ;  64/40 _____@_____
+               .byte   $0A     ;  65/41 _____A_____
+               .byte   $0A     ;  66/42 _____B_____
+               .byte   $0A     ;  67/43 _____C_____
+               .byte   $0A     ;  68/44 _____D_____
+               .byte   $0A     ;  69/45 _____E_____
+               .byte   $0A     ;  70/46 _____F_____
+               .byte   $02     ;  71/47 _____G_____
+               .byte   $02     ;  72/48 _____H_____
+               .byte   $02     ;  73/49 _____I_____
+               .byte   $02     ;  74/4a _____J_____
+               .byte   $02     ;  75/4b _____K_____
+               .byte   $02     ;  76/4c _____L_____
+               .byte   $02     ;  77/4d _____M_____
+               .byte   $02     ;  78/4e _____N_____
+               .byte   $02     ;  79/4f _____O_____
+               .byte   $02     ;  80/50 _____P_____
+               .byte   $02     ;  81/51 _____Q_____
+               .byte   $02     ;  82/52 _____R_____
+               .byte   $02     ;  83/53 _____S_____
+               .byte   $02     ;  84/54 _____T_____
+               .byte   $02     ;  85/55 _____U_____
+               .byte   $02     ;  86/56 _____V_____
+               .byte   $02     ;  87/57 _____W_____
+               .byte   $02     ;  88/58 _____X_____
+               .byte   $02     ;  89/59 _____Y_____
+               .byte   $02     ;  90/5a _____Z_____
+       .byte   $00     ;  91/5b _____[_____
+       .byte   $00     ;  92/5c _____\_____
+       .byte   $00     ;  93/5d _____]_____
+       .byte   $00     ;  94/5e _____^_____
+       .byte   $00     ;  95/5f _UNDERLINE_
+       .byte   $00     ;  96/60 ___grave___
+               .byte   $09     ;  97/61 _____a_____
+               .byte   $09     ;  98/62 _____b_____
+               .byte   $09     ;  99/63 _____c_____
+               .byte   $09     ; 100/64 _____d_____
+               .byte   $09     ; 101/65 _____e_____
+               .byte   $09     ; 102/66 _____f_____
+               .byte   $01     ; 103/67 _____g_____
+               .byte   $01     ; 104/68 _____h_____
+               .byte   $01     ; 105/69 _____i_____
+               .byte   $01     ; 106/6a _____j_____
+               .byte   $01     ; 107/6b _____k_____
+               .byte   $01     ; 108/6c _____l_____
+               .byte   $01     ; 109/6d _____m_____
+               .byte   $01     ; 110/6e _____n_____
+               .byte   $01     ; 111/6f _____o_____
+               .byte   $01     ; 112/70 _____p_____
+               .byte   $01     ; 113/71 _____q_____
+               .byte   $01     ; 114/72 _____r_____
+               .byte   $01     ; 115/73 _____s_____
+               .byte   $01     ; 116/74 _____t_____
+               .byte   $01     ; 117/75 _____u_____
+               .byte   $01     ; 118/76 _____v_____
+               .byte   $01     ; 119/77 _____w_____
+               .byte   $01     ; 120/78 _____x_____
+               .byte   $01     ; 121/79 _____y_____
+               .byte   $01     ; 122/7a _____z_____
+               .byte   $00     ; 123/7b _____{_____
+               .byte   $00     ; 124/7c _____|_____
+               .byte   $00     ; 125/7d _____}_____
+               .byte   $00     ; 126/7e _____~_____
+               .byte   $40     ; 127/7f ____DEL____
+
+               .byte   $00     ; 128/80 ___________
+               .byte   $00     ; 129/81 ___________
+               .byte   $00     ; 130/82 ___________
+               .byte   $00     ; 131/83 ___________
+               .byte   $00     ; 132/84 ___________
+               .byte   $00     ; 133/85 ___________
+               .byte   $00     ; 134/86 ___________
+               .byte   $00     ; 135/87 ___________
+               .byte   $00     ; 136/88 ___________
+               .byte   $00     ; 137/89 ___________
+               .byte   $00     ; 138/8a ___________
+               .byte   $00     ; 139/8b ___________
+               .byte   $00     ; 140/8c ___________
+               .byte   $00     ; 141/8d ___________
+               .byte   $00     ; 142/8e ___________
+               .byte   $00     ; 143/8f ___________
+               .byte   $00     ; 144/90 ___________
+               .byte   $00     ; 145/91 ___________
+               .byte   $00     ; 146/92 ___________
+               .byte   $10     ; 147/93 ___________
+               .byte   $00     ; 148/94 ___________
+               .byte   $00     ; 149/95 ___________
+               .byte   $00     ; 150/96 ___________
+               .byte   $00     ; 151/97 ___________
+               .byte   $00     ; 152/98 ___________
+               .byte   $00     ; 153/99 ___________
+               .byte   $00     ; 154/9a ___________
+               .byte   $00     ; 155/9b ___________
+               .byte   $00     ; 156/9c ___________
+               .byte   $00     ; 157/9d ___________
+               .byte   $00     ; 158/9e ___________
+               .byte   $00     ; 159/9f ___________
+
+               .byte   $00     ; 160/a0 ___________
+               .byte   $00     ; 161/a1 ___________
+               .byte   $00     ; 162/a2 ___________
+               .byte   $00     ; 163/a3 ___________
+               .byte   $00     ; 164/a4 ___________
+               .byte   $00     ; 165/a5 ___________
+               .byte   $00     ; 166/a6 ___________
+               .byte   $00     ; 167/a7 ___________
+               .byte   $00     ; 168/a8 ___________
+               .byte   $00     ; 169/a9 ___________
+               .byte   $00     ; 170/aa ___________
+               .byte   $00     ; 171/ab ___________
+               .byte   $00     ; 172/ac ___________
+               .byte   $00     ; 173/ad ___________
+               .byte   $00     ; 174/ae ___________
+               .byte   $00     ; 175/af ___________
+               .byte   $00     ; 176/b0 ___________
+               .byte   $00     ; 177/b1 ___________
+               .byte   $00     ; 178/b2 ___________
+               .byte   $00     ; 179/b3 ___________
+               .byte   $00     ; 180/b4 ___________
+               .byte   $00     ; 181/b5 ___________
+               .byte   $00     ; 182/b6 ___________
+               .byte   $00     ; 183/b7 ___________
+               .byte   $00     ; 184/b8 ___________
+               .byte   $00     ; 185/b9 ___________
+               .byte   $00     ; 186/ba ___________
+               .byte   $00     ; 187/bb ___________
+               .byte   $00     ; 188/bc ___________
+               .byte   $00     ; 189/bd ___________
+               .byte   $00     ; 190/be ___________
+               .byte   $00     ; 191/bf ___________
+
+               .byte   $02     ; 192/c0 ___________
+               .byte   $02     ; 193/c1 ___________
+               .byte   $02     ; 194/c2 ___________
+               .byte   $02     ; 195/c3 ___________
+               .byte   $02     ; 196/c4 ___________
+               .byte   $02     ; 197/c5 ___________
+               .byte   $02     ; 198/c6 ___________
+               .byte   $02     ; 199/c7 ___________
+               .byte   $02     ; 200/c8 ___________
+               .byte   $02     ; 201/c9 ___________
+               .byte   $02     ; 202/ca ___________
+               .byte   $02     ; 203/cb ___________
+               .byte   $02     ; 204/cc ___________
+               .byte   $02     ; 205/cd ___________
+               .byte   $02     ; 206/ce ___________
+               .byte   $02     ; 207/cf ___________
+               .byte   $02     ; 208/d0 ___________
+               .byte   $02     ; 209/d1 ___________
+               .byte   $02     ; 210/d2 ___________
+               .byte   $02     ; 211/d3 ___________
+               .byte   $02     ; 212/d4 ___________
+               .byte   $02     ; 213/d5 ___________
+               .byte   $02     ; 214/d6 ___________
+               .byte   $02     ; 215/d7 ___________
+               .byte   $02     ; 216/d8 ___________
+               .byte   $02     ; 217/d9 ___________
+               .byte   $02     ; 218/da ___________
+               .byte   $02     ; 219/db ___________
+               .byte   $02     ; 220/dc ___________
+               .byte   $02     ; 221/dd ___________
+               .byte   $02     ; 222/de ___________
+               .byte   $00     ; 223/df ___________
+               .byte   $01     ; 224/e0 ___________
+               .byte   $01     ; 225/e1 ___________
+               .byte   $01     ; 226/e2 ___________
+               .byte   $01     ; 227/e3 ___________
+               .byte   $01     ; 228/e4 ___________
+               .byte   $01     ; 229/e5 ___________
+               .byte   $01     ; 230/e6 ___________
+               .byte   $01     ; 231/e7 ___________
+               .byte   $01     ; 232/e8 ___________
+               .byte   $01     ; 233/e9 ___________
+               .byte   $01     ; 234/ea ___________
+               .byte   $01     ; 235/eb ___________
+               .byte   $01     ; 236/ec ___________
+               .byte   $01     ; 237/ed ___________
+               .byte   $01     ; 238/ee ___________
+               .byte   $01     ; 239/ef ___________
+               .byte   $01     ; 240/f0 ___________
+               .byte   $01     ; 241/f1 ___________
+               .byte   $01     ; 242/f2 ___________
+               .byte   $01     ; 243/f3 ___________
+               .byte   $01     ; 244/f4 ___________
+               .byte   $01     ; 245/f5 ___________
+               .byte   $01     ; 246/f6 ___________
+               .byte   $01     ; 247/f7 ___________
+               .byte   $01     ; 248/f8 ___________
+               .byte   $01     ; 249/f9 ___________
+               .byte   $01     ; 250/fa ___________
+               .byte   $01     ; 251/fb ___________
+               .byte   $01     ; 252/fc ___________
+               .byte   $01     ; 253/fd ___________
+               .byte   $01     ; 254/fe ___________
+               .byte   $00     ; 255/ff ___________
+
diff --git a/libsrc/atmos/cvline.s b/libsrc/atmos/cvline.s
new file mode 100644 (file)
index 0000000..09eea4c
--- /dev/null
@@ -0,0 +1,36 @@
+;
+; Ullrich von Bassewitz, 2003-04-13
+;
+; void cvlinexy (unsigned char x, unsigned char y, unsigned char length);
+; void cvline (unsigned char length);
+;
+
+       .export         _cvlinexy, _cvline
+        .import         setscrptr
+        .import         rvs
+       .import         popax
+        .importzp       ptr2
+
+        .include        "atmos.inc"
+
+
+_cvlinexy:
+               pha                     ; Save the length
+       jsr     popax           ; Get X and Y
+        sta     CURS_Y          ; Store Y
+        stx     CURS_X          ; Store X
+               pla                     ; Restore the length and run into _cvline
+
+_cvline:
+               tax                     ; Is the length zero?
+               beq     @L9             ; Jump if done
+@L1:    jsr     setscrptr       ; Set ptr2 to screen, won't use X
+        lda     #'|'
+        ora     rvs
+        sta     (ptr2),y        ; Write one char
+        inc     CURS_Y
+@L2:    dex
+        bne     @L1
+@L9:   rts
+
+
diff --git a/libsrc/atmos/gotox.s b/libsrc/atmos/gotox.s
new file mode 100644 (file)
index 0000000..25ed7fb
--- /dev/null
@@ -0,0 +1,18 @@
+;
+; Ullrich von Bassewitz, 2003-04-13
+;
+; void gotox (unsigned char x);
+;
+
+       .export         _gotox
+
+        .include        "atmos.inc"
+
+.proc   _gotox
+
+       sta     CURS_X          ; Set X
+        rts
+
+.endproc
+
+
diff --git a/libsrc/atmos/gotoxy.s b/libsrc/atmos/gotoxy.s
new file mode 100644 (file)
index 0000000..26a16bb
--- /dev/null
@@ -0,0 +1,21 @@
+;
+; Ullrich von Bassewitz, 2003-04-13
+;
+; void gotoxy (unsigned char x, unsigned char y);
+;
+
+       .export         _gotoxy
+       .import         popa
+
+        .include        "atmos.inc"
+
+.proc   _gotoxy
+
+       sta     CURS_Y          ; Set Y
+       jsr     popa            ; Get X
+       sta     CURS_X          ; Set X
+        rts
+
+.endproc
+
+
diff --git a/libsrc/atmos/gotoy.s b/libsrc/atmos/gotoy.s
new file mode 100644 (file)
index 0000000..baa95a7
--- /dev/null
@@ -0,0 +1,18 @@
+;
+; Ullrich von Bassewitz, 2003-04-13
+;
+; void gotoy (unsigned char y);
+;
+
+       .export         _gotoy
+
+        .include        "atmos.inc"
+
+.proc   _gotoy
+
+       sta     CURS_Y          ; Set Y
+        rts
+
+.endproc
+
+
diff --git a/libsrc/atmos/kbhit.s b/libsrc/atmos/kbhit.s
new file mode 100644 (file)
index 0000000..df36226
--- /dev/null
@@ -0,0 +1,18 @@
+;
+; Ullrich von Bassewitz, 2003-04-13
+;
+; int kbhit (void);
+;
+
+       .export         _kbhit
+
+       .include        "atmos.inc"
+
+_kbhit:
+        ldx     #$00            ; Load high byte
+        lda     KEYBUF          ; Flag for new char in bit 7
+        asl     a               ; Shift bit 7 into carry
+        txa                     ; A = 0
+        rol     a               ; Move old bit 7 into bit 0
+        rts
+
diff --git a/libsrc/atmos/revers.s b/libsrc/atmos/revers.s
new file mode 100644 (file)
index 0000000..07334af
--- /dev/null
@@ -0,0 +1,37 @@
+;
+; Ullrich von Bassewitz, 07.08.1998
+;
+; unsigned char revers (unsigned char onoff);
+;
+
+       .export         _revers
+        .export         rvs
+
+; ------------------------------------------------------------------------
+;
+
+.code
+.proc   _revers
+
+       ldx     #$00            ; Assume revers off
+       tay                     ; Test onoff
+       beq     L1              ; Jump if off
+       ldx     #$80            ; Load on value
+        ldy    #$00            ; Assume old value is zero
+L1:     lda            rvs             ; Load old value
+       stx     rvs             ; Set new value
+       beq     L2              ; Jump if old value zero
+       iny                     ; Make old value = 1
+L2:    ldx     #$00            ; Load high byte of result
+       tya                     ; Load low byte, set CC
+       rts
+
+.endproc
+
+; ------------------------------------------------------------------------
+;
+
+.bss
+rvs:    .res    1
+
+
diff --git a/libsrc/atmos/wherex.s b/libsrc/atmos/wherex.s
new file mode 100644 (file)
index 0000000..649f1ad
--- /dev/null
@@ -0,0 +1,18 @@
+;
+; Ullrich von Bassewitz, 2003-04-13
+;
+; unsigned char wherex (void);
+;
+
+       .export         _wherex
+
+        .include        "atmos.inc"
+
+.proc   _wherex
+
+        ldx     #$00
+        lda     CURS_X
+       rts
+
+.endproc
+
diff --git a/libsrc/atmos/wherey.s b/libsrc/atmos/wherey.s
new file mode 100644 (file)
index 0000000..3a940c5
--- /dev/null
@@ -0,0 +1,19 @@
+;
+; Ullrich von Bassewitz, 2003-04-13
+;
+; unsigned char wherey (void);
+;
+
+       .export         _wherey
+
+        .include        "atmos.inc"
+
+.proc   _wherey
+
+        ldx     #$00
+        lda     CURS_Y
+       rts
+
+.endproc
+
+
diff --git a/libsrc/atmos/write.s b/libsrc/atmos/write.s
new file mode 100644 (file)
index 0000000..d5a693a
--- /dev/null
@@ -0,0 +1,55 @@
+;
+; Ullrich von Bassewitz, 2003-04-13
+;
+; int write (int fd, const void* buf, int count);
+;
+; This function is a hack!
+;
+
+       .export         _write
+       .import         popax
+       .importzp       ptr1, ptr2, ptr3, tmp1
+
+       .include        "atmos.inc"
+
+.proc   _write
+
+       sta     ptr3
+       sta     ptr3+1          ; save count as result
+
+        eor     #$FF
+        sta     ptr2
+        txa
+        eor     #$FF
+        sta     ptr2+1          ; Remember -count-1
+
+       jsr     popax           ; get buf
+       sta     ptr1
+       stx     ptr1+1
+       jsr     popax           ; get fd and discard
+L1:    inc     ptr2
+        bne     L2
+        inc     ptr2+1
+        beq     L9
+L2:     ldy     #0
+       lda     (ptr1),y
+        tax
+        cpx     #$0A            ; Check for \n
+        bne     L3
+        jsr     PRINT
+        ldx     #$0D
+L3:     jsr     PRINT
+       inc     ptr1
+       bne     L1
+       inc     ptr1+1
+        jmp     L1
+
+; No error, return count
+
+L9:    lda     ptr3
+       ldx     ptr3+1
+       rts
+
+.endproc
+
+