Cleanups for Creativision.

This commit is contained in:
Christian Groessler
2017-02-01 19:46:04 +01:00
parent 0b2a699b46
commit a08f905224
22 changed files with 291 additions and 314 deletions

View File

@@ -2,14 +2,14 @@
;** _scrsize.s
;*
.export screensize
.export screensize
.include "creativision.inc"
.include "creativision.inc"
.proc screensize
ldx #SCREEN_COLS
ldy #SCREEN_ROWS
rts
ldx #SCREEN_COLS
ldy #SCREEN_ROWS
rts
.endproc

View File

@@ -1,62 +1,62 @@
; Boxchars
boxchars:
; Vertical Line
.byte $18
.byte $18
.byte $18
.byte $18
.byte $18
.byte $18
.byte $18
.byte $18
; Vertical Line
.byte $18
.byte $18
.byte $18
.byte $18
.byte $18
.byte $18
.byte $18
.byte $18
; Horizontal Line
.byte 0
.byte 0
.byte 0
.byte $ff
.byte 0
.byte 0
.byte 0
.byte 0
; Top Left
.byte 0
.byte 0
.byte 0
.byte $1f
.byte $18
.byte $18
.byte $18
.byte $18
; Top Right
.byte 0
.byte 0
.byte 0
.byte $F8
.byte $18
.byte $18
.byte $18
.byte $18
; Horizontal Line
.byte $00
.byte $00
.byte $00
.byte $FF
.byte $00
.byte $00
.byte $00
.byte $00
; Bottom Left
.byte $18
.byte $18
.byte $18
.byte $1F
.byte 0
.byte 0
.byte 0
.byte 0
; Top Left
.byte $00
.byte $00
.byte $00
.byte $1F
.byte $18
.byte $18
.byte $18
.byte $18
; Bottom Right
.byte $18
.byte $18
.byte $18
.byte $F8
.byte 0
.byte 0
.byte 0
.byte 0
; Top Right
.byte $00
.byte $00
.byte $00
.byte $F8
.byte $18
.byte $18
.byte $18
.byte $18
; Bottom Left
.byte $18
.byte $18
.byte $18
.byte $1F
.byte $00
.byte $00
.byte $00
.byte $00
; Bottom Right
.byte $18
.byte $18
.byte $18
.byte $F8
.byte $00
.byte $00
.byte $00
.byte $00

View File

@@ -3,27 +3,24 @@
;* void cclear (unsigned char length);
;*
.export _cclearxy, _cclear
.import popa, _gotoxy, cputdirect
.importzp tmp1
_cclearxy:
pha ; Save length
jsr popa ; get Y
jsr _gotoxy
pla
_cclear:
cmp #0 ; Zero length?
beq L2
sta tmp1
L1:
lda #$20 ; Space
jsr cputdirect
dec tmp1
bne L1
L2: rts
.export _cclearxy, _cclear
.import popa, _gotoxy, cputdirect
.importzp tmp1
_cclearxy:
pha ; Save length
jsr popa ; get Y
jsr _gotoxy
pla
_cclear:
cmp #0 ; Zero length?
beq L2
sta tmp1
L1: lda #$20 ; Space
jsr cputdirect
dec tmp1
bne L1
L2: rts

View File

@@ -1,17 +1,14 @@
;* cgetc
.export _cgetc
.include "creativision.inc"
.export _cgetc
.include "creativision.inc"
_cgetc:
lda #$80
L1:
bit ZP_KEYBOARD
bpl L1
lda ZP_KEYBOARD
and #$7f
rts
lda #$80
L1: bit ZP_KEYBOARD
bpl L1
lda ZP_KEYBOARD
and #$7F
rts

View File

@@ -6,7 +6,7 @@
.importzp tmp1
.include "creativision.inc"
_chlinexy:
pha ; Save the length
jsr popa ; Get y

View File

@@ -4,38 +4,38 @@
;* NB: All screen functions assume Graphics Mode 1 in a default configuration.
;* Therefore, this is hard coded to use $1000-$12FF as screen VRAM.
.export _clrscr
.include "creativision.inc"
.export _clrscr
.include "creativision.inc"
_clrscr:
sei ; Disable interrupts. Default INT handler reads VDP_STATUS
; and would lose any setup done here.
lda #$00 ; VRAM offset low
sta VDP_CONTROL_W
lda #$50 ; VRAM offset high ($10 OR $40)
sta VDP_CONTROL_W
lda #$C0 ; Space from ROM setup
ldx #0
ldy #3
L1: sta VDP_DATA_W
inx
bne L1
dey
bne L1
cli ; Let interrupts go again
lda #0
sta CURSOR_X
sta CURSOR_Y
sta <SCREEN_PTR
lda #$10
sta >SCREEN_PTR
rts
sei ; Disable interrupts. Default INT handler reads VDP_STATUS
; and would lose any setup done here.
lda #$00 ; VRAM offset low
sta VDP_CONTROL_W
lda #$50 ; VRAM offset high ($10 OR $40)
sta VDP_CONTROL_W
lda #$C0 ; Space from ROM setup
ldx #0
ldy #3
L1: sta VDP_DATA_W
inx
bne L1
dey
bne L1
cli ; Let interrupts go again
lda #0
sta CURSOR_X
sta CURSOR_Y
sta <SCREEN_PTR
lda #$10
sta >SCREEN_PTR
rts

View File

@@ -4,10 +4,10 @@
;* unsigned char __fastcall__ bordercolor (unsigned char color);
;*
.export _textcolor, _bgcolor, _bordercolor
.import return0
.include "creativision.inc"
_bordercolor = return0;
_textcolor = return0;
_bgcolor = return0;
.export _textcolor, _bgcolor, _bordercolor
.import return0
.include "creativision.inc"
_bordercolor = return0;
_textcolor = return0;
_bgcolor = return0;

View File

@@ -29,13 +29,13 @@ _cputcxy:
; Plot a character - also used as internal function
_cputc: cmp #$0d ; CR?
_cputc: cmp #$0D ; CR?
bne L1
lda #0
sta CURSOR_X
beq plot ; Recalculate pointers
L1: cmp #$0a ; LF?
L1: cmp #$0A ; LF?
beq newline ; Recalculate pointers
; Printable char of some sort
@@ -82,19 +82,19 @@ IS_UPPER:
pha
lda SCREEN_PTR
sei
sta VDP_CONTROL_W
sta VDP_CONTROL_W
lda SCREEN_PTR+1
ora #$40
sta VDP_CONTROL_W
ora #$40
sta VDP_CONTROL_W
pla
clc
adc #160
sta VDP_DATA_W
adc #160
sta VDP_DATA_W
cli
BAD_CHAR:
jmp plot
;-----------------------------------------------------------------------------
; Initialize the conio subsystem. Code goes into the INIT segment, which may
; be reused after startup.
@@ -102,24 +102,24 @@ BAD_CHAR:
.segment "INIT"
initconio:
lda #$0
sta SCREEN_PTR
lda #$10
sta SCREEN_PTR+1
lda #$0
sta SCREEN_PTR
lda #$10
sta SCREEN_PTR+1
; Copy box characters to slot
sei
lda #08
sta VDP_CONTROL_W
lda #$46
sta VDP_CONTROL_W
ldx #0
LL:
lda boxchars,x
sta VDP_DATA_W
inx
cpx #48
bne LL
; Copy box characters to slot
sei
lda #08
sta VDP_CONTROL_W
lda #$46
sta VDP_CONTROL_W
ldx #0
cli
jmp plot
LL: lda boxchars,x
sta VDP_DATA_W
inx
cpx #48
bne LL
cli
jmp plot

View File

@@ -11,7 +11,7 @@
.proc _gotox
sta CURSOR_X ; Set new position
sta CURSOR_X ; Set new position
tay
ldx CURSOR_Y
jmp setcursor ; Set the cursor to the new position

View File

@@ -12,9 +12,9 @@
.proc _gotoxy
sta CURSOR_Y ; Set Y
jsr popa ; Get X
sta CURSOR_X ; Set X
sta CURSOR_Y ; Set Y
jsr popa ; Get X
sta CURSOR_X ; Set X
tay
ldx CURSOR_Y
jmp setcursor ; Set the cursor position

View File

@@ -1,6 +1,6 @@
;*
;* Creativision Joystick Function
;*
;*
;* unsigned char __fastcall__ joystate(unsigned char joy);
;*
;* JOY_1 -> Return Left Joystick direction
@@ -12,47 +12,47 @@
.export _joystate
.include "creativision.inc"
_joystate:
cmp #1 ; Left Direction
bne l1
lda $11
beq l5
and #$f
and #$0F
lsr a
tax
inx
txa
rts
l1: cmp #2 ; Right Direction
bne l2
lda $13
beq l5
and #$f
and #$0F
lsr a
tax
inx
txa
rts
l2: cmp #3 ; Left Buttons
bne l3
lda $16
beq l5
and #$f
and #$0F
rts
l3: cmp #4
bne l4
lda $17
beq l5
and #$f
and #$0F
rts
l4: lda #0
l5: rts

View File

@@ -5,5 +5,5 @@
.export joy_libref, tgi_libref
.import _exit
joy_libref := _exit
tgi_libref := _exit
joy_libref := _exit
tgi_libref := _exit

View File

@@ -20,5 +20,3 @@
rts
.endproc

View File

@@ -3,40 +3,37 @@
; void __fastcall__ bios_playsound( void *b, unsigned char c);
; void psg_silence( void );
.export _psg_outb, _psg_silence, _psg_delay
.export _bios_playsound
.import popa
.include "creativision.inc"
.export _psg_outb, _psg_silence, _psg_delay
.export _bios_playsound
.import popa
.include "creativision.inc"
_psg_outb:
;* Let BIOS output the value
jmp $FE77
;* Let BIOS output the value
jmp $FE77
_psg_silence:
jmp $FE54
jmp $FE54
_psg_delay:
tay
l1:
lda #200
l2:
sbc #1
bne l2
lda #200
l3:
sbc #1
bne l3
dey
bne l1
rts
tay
l1: lda #200
l2: sbc #1
bne l2
lda #200
l3: sbc #1
bne l3
dey
bne l1
rts
;* Creativision Sound Player
;*
@@ -46,23 +43,21 @@ l3:
_bios_playsound:
pha ; Save Length Byte
sei
lda #$D5 ; BIOS volume table low
sta $4
lda #$FC ; BIOS volume table high
sta $5
jsr popa ; Get Sound table pointer low
sta $0
jsr popa ; Get Sound table pointer high
sta $1
pla
tay ; Put length in Y
dey
php
jmp $fbed ; Let BIOS do it's thing
pha ; Save Length Byte
sei
lda #$D5 ; BIOS volume table low
sta $4
lda #$FC ; BIOS volume table high
sta $5
jsr popa ; Get Sound table pointer low
sta $0
jsr popa ; Get Sound table pointer high
sta $1
pla
tay ; Put length in Y
dey
php
jmp $FBED ; Let BIOS do it's thing

View File

@@ -34,6 +34,3 @@ utsdata:
; machine
.asciiz "CREATIVISION"

View File

@@ -5,7 +5,6 @@
;
.export _wherex
.include "creativision.inc"
.proc _wherex
@@ -15,5 +14,3 @@
rts
.endproc

View File

@@ -5,7 +5,6 @@
;
.export _wherey
.include "creativision.inc"
.proc _wherey
@@ -15,5 +14,3 @@
rts
.endproc