changes from Fatih

git-svn-id: svn://svn.cc65.org/cc65/trunk@4468 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cpg
2009-11-15 14:46:09 +00:00
parent 097b094fdd
commit b739a2d335
16 changed files with 404 additions and 330 deletions

View File

@@ -22,23 +22,23 @@
; ---------------------------------------------------------------------- ; ----------------------------------------------------------------------
; Graphics mode ; Graphics mode
.define grmode 10 grmode = 10
; X resolution ; X resolution
.define x_res 80 x_res = 80
; Y resolution ; Y resolution
.define y_res 192 y_res = 192
; Number of colors ; Number of colors
.define colors 9 colors = 9
; Pixels per byte ; Pixels per byte
.define ppb 2 ppb = 2
; Screen memory size in bytes ; Screen memory size in bytes
.define scrsize x_res * y_res / ppb scrsize = x_res * y_res / ppb
; Pixel aspect ratio ; Pixel aspect ratio
.define aspect $0400 ; 4:1 aspect = $0400 ; 4:1
; Free memory needed ; Free memory needed
.define mem_needed 7147 mem_needed = 7147
; Number of screen pages ; Number of screen pages
.define pages 1 pages = 1
.rodata .rodata
mask_table: ; Mask table to set pixels mask_table: ; Mask table to set pixels

View File

@@ -22,23 +22,23 @@
; ---------------------------------------------------------------------- ; ----------------------------------------------------------------------
; Graphics mode ; Graphics mode
.define grmode 10 grmode = 10
; X resolution ; X resolution
.define x_res 80 x_res = 80
; Y resolution ; Y resolution
.define y_res 192 y_res = 192
; Number of colors ; Number of colors
.define colors 9 colors = 9
; Pixels per byte ; Pixels per byte
.define ppb 2 ppb = 2
; Screen memory size in bytes ; Screen memory size in bytes
.define scrsize x_res * y_res / ppb scrsize = x_res * y_res / ppb
; Pixel aspect ratio ; Pixel aspect ratio
.define aspect $0400 ; 4:1 aspect = $0400 ; 4:1
; Free memory needed ; Free memory needed
.define mem_needed 15339 mem_needed = 15339
; Number of screen pages ; Number of screen pages
.define pages 2 pages = 2
.rodata .rodata
mask_table: ; Mask table to set pixels mask_table: ; Mask table to set pixels

View File

@@ -22,23 +22,23 @@
; ---------------------------------------------------------------------- ; ----------------------------------------------------------------------
; Graphics mode ; Graphics mode
.define grmode 11 grmode = 11
; X resolution ; X resolution
.define x_res 80 x_res = 80
; Y resolution ; Y resolution
.define y_res 192 y_res = 192
; Number of colors ; Number of colors
.define colors 16 colors = 16
; Pixels per byte ; Pixels per byte
.define ppb 2 ppb = 2
; Screen memory size in bytes ; Screen memory size in bytes
.define scrsize x_res * y_res / ppb scrsize = x_res * y_res / ppb
; Pixel aspect ratio ; Pixel aspect ratio
.define aspect $0400 ; 4:1 aspect = $0400 ; 4:1
; Free memory needed ; Free memory needed
.define mem_needed 7147 mem_needed = 7147
; Number of screen pages ; Number of screen pages
.define pages 1 pages = 1
.rodata .rodata
mask_table: ; Mask table to set pixels mask_table: ; Mask table to set pixels

View File

@@ -22,23 +22,23 @@
; ---------------------------------------------------------------------- ; ----------------------------------------------------------------------
; Graphics mode ; Graphics mode
.define grmode 14 grmode = 14
; X resolution ; X resolution
.define x_res 160 x_res = 160
; Y resolution ; Y resolution
.define y_res 192 y_res = 192
; Number of colors ; Number of colors
.define colors 2 colors = 2
; Pixels per byte ; Pixels per byte
.define ppb 8 ppb = 8
; Screen memory size in bytes ; Screen memory size in bytes
.define scrsize x_res * y_res / ppb scrsize = x_res * y_res / ppb
; Pixel aspect ratio ; Pixel aspect ratio
.define aspect $0200 ; 2:1 aspect = $0200 ; 2:1
; Free memory needed ; Free memory needed
.define mem_needed 3305 mem_needed = 3305
; Number of screen pages ; Number of screen pages
.define pages 1 pages = 1
.rodata .rodata
mask_table: ; Mask table to set pixels mask_table: ; Mask table to set pixels

View File

@@ -22,23 +22,23 @@
; ---------------------------------------------------------------------- ; ----------------------------------------------------------------------
; Graphics mode ; Graphics mode
.define grmode 15 grmode = 15
; X resolution ; X resolution
.define x_res 160 x_res = 160
; Y resolution ; Y resolution
.define y_res 192 y_res = 192
; Number of colors ; Number of colors
.define colors 4 colors = 4
; Pixels per byte ; Pixels per byte
.define ppb 4 ppb = 4
; Screen memory size in bytes ; Screen memory size in bytes
.define scrsize x_res * y_res / ppb scrsize = x_res * y_res / ppb
; Pixel aspect ratio ; Pixel aspect ratio
.define aspect $0200 ; 2:1 aspect = $0200 ; 2:1
; Free memory needed ; Free memory needed
.define mem_needed 7147 mem_needed = 7147
; Number of screen pages ; Number of screen pages
.define pages 1 pages = 1
.rodata .rodata
mask_table: ; Mask table to set pixels mask_table: ; Mask table to set pixels

View File

@@ -22,23 +22,23 @@
; ---------------------------------------------------------------------- ; ----------------------------------------------------------------------
; Graphics mode ; Graphics mode
.define grmode 15 grmode = 15
; X resolution ; X resolution
.define x_res 160 x_res = 160
; Y resolution ; Y resolution
.define y_res 192 y_res = 192
; Number of colors ; Number of colors
.define colors 4 colors = 4
; Pixels per byte ; Pixels per byte
.define ppb 4 ppb = 4
; Screen memory size in bytes ; Screen memory size in bytes
.define scrsize x_res * y_res / ppb scrsize = x_res * y_res / ppb
; Pixel aspect ratio ; Pixel aspect ratio
.define aspect $0200 ; 2:1 aspect = $0200 ; 2:1
; Free memory needed ; Free memory needed
.define mem_needed 15339 mem_needed = 15339
; Number of screen pages ; Number of screen pages
.define pages 2 pages = 2
.rodata .rodata
mask_table: ; Mask table to set pixels mask_table: ; Mask table to set pixels

View File

@@ -22,23 +22,23 @@
; ---------------------------------------------------------------------- ; ----------------------------------------------------------------------
; Graphics mode ; Graphics mode
.define grmode 3 grmode = 3
; X resolution ; X resolution
.define x_res 40 x_res = 40
; Y resolution ; Y resolution
.define y_res 24 y_res = 24
; Number of colors ; Number of colors
.define colors 4 colors = 4
; Pixels per byte ; Pixels per byte
.define ppb 4 ppb = 4
; Screen memory size in bytes ; Screen memory size in bytes
.define scrsize x_res * y_res / ppb scrsize = x_res * y_res / ppb
; Pixel aspect ratio ; Pixel aspect ratio
.define aspect $0100 ; 1:1 aspect = $0100 ; 1:1
; Free memory needed ; Free memory needed
.define mem_needed 1 mem_needed = 1
; Number of screen pages ; Number of screen pages
.define pages 1 pages = 1
.rodata .rodata
mask_table: ; Mask table to set pixels mask_table: ; Mask table to set pixels
@@ -62,6 +62,7 @@
; ;
; ---------------------------------------------------------------------- ; ----------------------------------------------------------------------
.code
; Copy the palette ; Copy the palette
ldy #colors - 1 ldy #colors - 1
loop: lda (ptr1),y loop: lda (ptr1),y

View File

@@ -22,23 +22,23 @@
; ---------------------------------------------------------------------- ; ----------------------------------------------------------------------
; Graphics mode ; Graphics mode
.define grmode 4 grmode = 4
; X resolution ; X resolution
.define x_res 80 x_res = 80
; Y resolution ; Y resolution
.define y_res 48 y_res = 48
; Number of colors ; Number of colors
.define colors 2 colors = 2
; Pixels per byte ; Pixels per byte
.define ppb 8 ppb = 8
; Screen memory size in bytes ; Screen memory size in bytes
.define scrsize x_res * y_res / ppb scrsize = x_res * y_res / ppb
; Pixel aspect ratio ; Pixel aspect ratio
.define aspect $0100 ; 1:1 aspect = $0100 ; 1:1
; Free memory needed ; Free memory needed
.define mem_needed 1 mem_needed = 1
; Number of screen pages ; Number of screen pages
.define pages 1 pages = 1
.rodata .rodata
mask_table: ; Mask table to set pixels mask_table: ; Mask table to set pixels

View File

@@ -22,23 +22,23 @@
; ---------------------------------------------------------------------- ; ----------------------------------------------------------------------
; Graphics mode ; Graphics mode
.define grmode 5 grmode = 5
; X resolution ; X resolution
.define x_res 80 x_res = 80
; Y resolution ; Y resolution
.define y_res 48 y_res = 48
; Number of colors ; Number of colors
.define colors 4 colors = 4
; Pixels per byte ; Pixels per byte
.define ppb 4 ppb = 4
; Screen memory size in bytes ; Screen memory size in bytes
.define scrsize x_res * y_res / ppb scrsize = x_res * y_res / ppb
; Pixel aspect ratio ; Pixel aspect ratio
.define aspect $0100 ; 1:1 aspect = $0100 ; 1:1
; Free memory needed ; Free memory needed
.define mem_needed 185 mem_needed = 185
; Number of screen pages ; Number of screen pages
.define pages 1 pages = 1
.rodata .rodata
mask_table: ; Mask table to set pixels mask_table: ; Mask table to set pixels

View File

@@ -22,23 +22,23 @@
; ---------------------------------------------------------------------- ; ----------------------------------------------------------------------
; Graphics mode ; Graphics mode
.define grmode 6 grmode = 6
; X resolution ; X resolution
.define x_res 160 x_res = 160
; Y resolution ; Y resolution
.define y_res 96 y_res = 96
; Number of colors ; Number of colors
.define colors 2 colors = 2
; Pixels per byte ; Pixels per byte
.define ppb 8 ppb = 8
; Screen memory size in bytes ; Screen memory size in bytes
.define scrsize x_res * y_res / ppb scrsize = x_res * y_res / ppb
; Pixel aspect ratio ; Pixel aspect ratio
.define aspect $0100 ; 1:1 aspect = $0100 ; 1:1
; Free memory needed ; Free memory needed
.define mem_needed 1193 mem_needed = 1193
; Number of screen pages ; Number of screen pages
.define pages 1 pages = 1
.rodata .rodata
mask_table: ; Mask table to set pixels mask_table: ; Mask table to set pixels

View File

@@ -22,23 +22,23 @@
; ---------------------------------------------------------------------- ; ----------------------------------------------------------------------
; Graphics mode ; Graphics mode
.define grmode 7 grmode = 7
; X resolution ; X resolution
.define x_res 160 x_res = 160
; Y resolution ; Y resolution
.define y_res 96 y_res = 96
; Number of colors ; Number of colors
.define colors 4 colors = 4
; Pixels per byte ; Pixels per byte
.define ppb 4 ppb = 4
; Screen memory size in bytes ; Screen memory size in bytes
.define scrsize x_res * y_res / ppb scrsize = x_res * y_res / ppb
; Pixel aspect ratio ; Pixel aspect ratio
.define aspect $0100 ; 1:1 aspect = $0100 ; 1:1
; Free memory needed ; Free memory needed
.define mem_needed 3209 mem_needed = 3209
; Number of screen pages ; Number of screen pages
.define pages 1 pages = 1
.rodata .rodata
mask_table: ; Mask table to set pixels mask_table: ; Mask table to set pixels

View File

@@ -22,23 +22,23 @@
; ---------------------------------------------------------------------- ; ----------------------------------------------------------------------
; Graphics mode ; Graphics mode
.define grmode 8 grmode = 8
; X resolution ; X resolution
.define x_res 320 x_res = 320
; Y resolution ; Y resolution
.define y_res 192 y_res = 192
; Number of colors ; Number of colors
.define colors 2 colors = 2
; Pixels per byte ; Pixels per byte
.define ppb 8 ppb = 8
; Screen memory size in bytes ; Screen memory size in bytes
.define scrsize x_res * y_res / ppb scrsize = x_res * y_res / ppb
; Pixel aspect ratio ; Pixel aspect ratio
.define aspect $0100 ; 1:1 aspect = $0100 ; 1:1
; Free memory needed ; Free memory needed
.define mem_needed 7147 mem_needed = 7147
; Number of screen pages ; Number of screen pages
.define pages 1 pages = 1
.rodata .rodata
mask_table: ; Mask table to set pixels mask_table: ; Mask table to set pixels

View File

@@ -22,23 +22,23 @@
; ---------------------------------------------------------------------- ; ----------------------------------------------------------------------
; Graphics mode ; Graphics mode
.define grmode 8 grmode = 8
; X resolution ; X resolution
.define x_res 320 x_res = 320
; Y resolution ; Y resolution
.define y_res 192 y_res = 192
; Number of colors ; Number of colors
.define colors 2 colors = 2
; Pixels per byte ; Pixels per byte
.define ppb 8 ppb = 8
; Screen memory size in bytes ; Screen memory size in bytes
.define scrsize x_res * y_res / ppb scrsize = x_res * y_res / ppb
; Pixel aspect ratio ; Pixel aspect ratio
.define aspect $0100 ; 1:1 aspect = $0100 ; 1:1
; Free memory needed ; Free memory needed
.define mem_needed 15339 mem_needed = 15339
; Number of screen pages ; Number of screen pages
.define pages 2 pages = 2
.rodata .rodata
mask_table: ; Mask table to set pixels mask_table: ; Mask table to set pixels

View File

@@ -22,23 +22,23 @@
; ---------------------------------------------------------------------- ; ----------------------------------------------------------------------
; Graphics mode ; Graphics mode
.define grmode 9 grmode = 9
; X resolution ; X resolution
.define x_res 80 x_res = 80
; Y resolution ; Y resolution
.define y_res 192 y_res = 192
; Number of colors ; Number of colors
.define colors 16 colors = 16
; Pixels per byte ; Pixels per byte
.define ppb 2 ppb = 2
; Screen memory size in bytes ; Screen memory size in bytes
.define scrsize x_res * y_res / ppb scrsize = x_res * y_res / ppb
; Pixel aspect ratio ; Pixel aspect ratio
.define aspect $0400 ; 4:1 aspect = $0400 ; 4:1
; Free memory needed ; Free memory needed
.define mem_needed 7147 mem_needed = 7147
; Number of screen pages ; Number of screen pages
.define pages 1 pages = 1
.rodata .rodata
mask_table: ; Mask table to set pixels mask_table: ; Mask table to set pixels

View File

@@ -22,23 +22,23 @@
; ---------------------------------------------------------------------- ; ----------------------------------------------------------------------
; Graphics mode ; Graphics mode
.define grmode 9 grmode = 9
; X resolution ; X resolution
.define x_res 80 x_res = 80
; Y resolution ; Y resolution
.define y_res 192 y_res = 192
; Number of colors ; Number of colors
.define colors 16 colors = 16
; Pixels per byte ; Pixels per byte
.define ppb 2 ppb = 2
; Screen memory size in bytes ; Screen memory size in bytes
.define scrsize x_res * y_res / ppb scrsize = x_res * y_res / ppb
; Pixel aspect ratio ; Pixel aspect ratio
.define aspect $0400 ; 4:1 aspect = $0400 ; 4:1
; Free memory needed ; Free memory needed
.define mem_needed 15339 mem_needed = 15339
; Number of screen pages ; Number of screen pages
.define pages 2 pages = 2
.rodata .rodata
mask_table: ; Mask table to set pixels mask_table: ; Mask table to set pixels

View File

@@ -2,6 +2,8 @@
; Generic Atari graphics driver ; Generic Atari graphics driver
; ;
.macpack longbranch
; ****************************************************************************** ; ******************************************************************************
; ---------------------------------------------------------------------- ; ----------------------------------------------------------------------
@@ -74,12 +76,14 @@
.bss .bss
error: error:
.res 1 ; Error code .res 1 ; Error code
.if grmode = 9 || grmode = 11
.if ::grmode = 9 || ::grmode = 11
palette = default_palette palette = default_palette
.else .else
palette: palette:
.res colors ; The current palette .res colors ; The current palette
.endif .endif
mask: mask:
.res 1 ; Current pixel mask .res 1 ; Current pixel mask
griocb: griocb:
@@ -144,23 +148,29 @@ screen_device_length := * - screen_device
.code .code
; Initialize drawing color ; Initialize drawing color
.if ::ppb = 8
ldx #$FF ldx #$FF
.elseif ::ppb = 4
ldx #$55
.elseif ::ppb = 2
ldx #$11
.endif
stx mask stx mask
; Find a free IOCB ; Find a free IOCB
clc
lda #$70 lda #$70
search: tax search: tax
ldy ICHID,x ldy ICHID,x
cpy #$FF cpy #$FF
beq found beq found
sbc #$10 sub #$10
bcs search bcs search
; Out of resources ; No free IOCB
nores: lda #TGI_ERR_NO_RES lda #TGI_ERR_NO_IOCB
sta error jmp exit
rts
found: ; Check if enough RAM is available found: ; Check if enough RAM is available
lda #0 lda #0
@@ -169,17 +179,21 @@ found: ; Check if enough RAM is available
lda RAMTOP lda RAMTOP
sbc #>mem_needed sbc #>mem_needed
cmp APPMHI + 1 cmp APPMHI + 1
bcc nores bcc nomem
bne switch bne switch
cpy APPMHI cpy APPMHI
bcc nores bcs switch
; No memory
nomem: lda #TGI_ERR_NO_MEM
jmp exit
; Switch into graphics mode ; Switch into graphics mode
switch: lda #OPEN switch: lda #OPEN
sta ICCOM,x sta ICCOM,x
lda #OPNIN | OPNOT lda #OPNIN | OPNOT
sta ICAX1,x sta ICAX1,x
lda #grmode lda #::grmode
sta ICAX2,x sta ICAX2,x
lda #<screen_device lda #<screen_device
sta ICBAL,x sta ICBAL,x
@@ -191,7 +205,7 @@ switch: lda #OPEN
sta ICBLH,x sta ICBLH,x
jsr CIOV jsr CIOV
.if pages = 2 .if ::pages = 2
; Reserve 8K of high memory ; Reserve 8K of high memory
lda RAMTOP lda RAMTOP
sub #32 sub #32
@@ -205,7 +219,7 @@ switch: lda #OPEN
sta ICCOM,x sta ICCOM,x
lda #OPNIN | OPNOT lda #OPNIN | OPNOT
sta ICAX1,x sta ICAX1,x
lda #grmode lda #::grmode
sta ICAX2,x sta ICAX2,x
lda #<screen_device lda #<screen_device
sta ICBAL,x sta ICBAL,x
@@ -216,17 +230,18 @@ switch: lda #OPEN
lda #>screen_device_length lda #>screen_device_length
sta ICBLH,x sta ICBLH,x
jsr CIOV jsr CIOV
; Save screen poniters ; Save screen pointers
lda SAVMSC + 1 lda SAVMSC + 1
sta p0scr sta p0scr
lda SDLSTH lda SDLSTH
sta p0dls sta p0dls
.endif .endif ; ::pages = 2
stx griocb stx griocb
; Reset the error code and return ; Reset the error code and return
lda #TGI_ERR_OK lda #TGI_ERR_OK
sta error exit: sta error
rts rts
.endproc .endproc
@@ -241,12 +256,13 @@ switch: lda #OPEN
; ---------------------------------------------------------------------- ; ----------------------------------------------------------------------
.code .code
.if pages = 2
.if ::pages = 2
; Free 8K of high memory ; Free 8K of high memory
lda RAMTOP lda RAMTOP
add #32 add #32
sta RAMTOP sta RAMTOP
.endif .endif
; Clear griocb ; Clear griocb
lda #$FF lda #$FF
@@ -275,7 +291,7 @@ switch: lda #OPEN
sta ICBLH,x sta ICBLH,x
jsr CIOV jsr CIOV
; Now close it again; we don't need it anymore ; Now close it again; we don't need it anymore :)
lda #CLOSE lda #CLOSE
sta ICCOM,x sta ICCOM,x
jmp CIOV jmp CIOV
@@ -319,24 +335,24 @@ switch: lda #OPEN
lda #0 lda #0
tay tay
.if >::scrsize > 0
; Clear full pages if any ; Clear full pages if any
.if >(scrsize) > 0 ldx #>::scrsize
ldx #>(scrsize)
loop1: sta (sptr),y loop1: sta (sptr),y
iny iny
bne loop1 bne loop1
inc sptr + 1 inc sptr + 1
dex dex
bne loop1 bne loop1
.endif .endif
.if <::scrsize > 0
; Clear the rest, if any ; Clear the rest, if any
.if <(scrsize) > 0
loop2: sta (sptr),y loop2: sta (sptr),y
iny iny
cpy #<(scrsize) cpy #<::scrsize
bne loop2 bne loop2
.endif .endif
rts rts
.endproc .endproc
@@ -385,14 +401,17 @@ loop2: sta (sptr),y
.code .code
tax tax
.if grmode = 9
.if ::grmode = 9
; Map colors like this: 0 -> 0, 1 -> 15, 2 -> 1, 3 -> 2 etc. ; Map colors like this: 0 -> 0, 1 -> 15, 2 -> 1, 3 -> 2 etc.
beq @cont beq cont
cpx #1 cpx #1
bne @map bne map
ldx #16 ldx #16
@map: dex map: dex
@cont: .endif cont:
.endif
lda masks,x lda masks,x
sta mask sta mask
rts rts
@@ -422,25 +441,28 @@ loop2: sta (sptr),y
sta temp sta temp
lda y1 lda y1
.if x_res / ppb = 40 .if ::x_res / ::ppb = 40
.define yrep 3 yrep = 3
.elseif x_res / ppb = 20 .elseif ::x_res / ::ppb = 20
.define yrep 2 yrep = 2
.elseif x_res / ppb = 10 .elseif ::x_res / ::ppb = 10
.define yrep 1 yrep = 1
.endif .endif
.repeat yrep
asl a
rol temp
.endrepeat
.repeat yrep
asl a
rol temp
.endrepeat
sta sptr sta sptr
ldx temp ldx temp
stx sptr + 1 stx sptr + 1
.repeat 2
.repeat 2
asl a asl a
rol temp rol temp
.endrepeat .endrepeat
add sptr add sptr
sta sptr sta sptr
lda temp lda temp
@@ -457,17 +479,19 @@ loop2: sta (sptr),y
sta temp sta temp
lda x1 lda x1
.if ppb = 8 .if ::ppb = 8
.define xrep 3 xrep = 3
.elseif ppb = 4 .elseif ::ppb = 4
.define xrep 2 xrep = 2
.elseif ppb = 2 .elseif ::ppb = 2
.define xrep 1 xrep = 1
.endif .endif
.repeat xrep
.repeat xrep
lsr temp lsr temp
ror a ror a
.endrepeat .endrepeat
tay tay
; sptr += SAVMSC ; sptr += SAVMSC
@@ -495,7 +519,7 @@ loop2: sta (sptr),y
.code .code
jsr CALC jsr CALC
put_pixel put_pixel
rts rts
.endproc .endproc
; ****************************************************************************** ; ******************************************************************************
@@ -512,44 +536,48 @@ loop2: sta (sptr),y
jsr CALC jsr CALC
lda (sptr),y lda (sptr),y
and mask_table,x and mask_table,x
.if ppb = 8
.if ::ppb = 8
beq zero beq zero
lda #1 lda #1
zero: ldx #0 zero: ldx #0
rts rts
.elseif ppb = 4 .elseif ::ppb = 4
loop: cpx #3 loop: cpx #3
beq cont beq done4
lsr a lsr a
lsr a lsr a
inx inx
bne loop bne loop
cont: and #$03 done4: and #$03
ldx #0
rts rts
.elseif ppb = 2 .elseif ::ppb = 2
dex dex
bne shift bne shift
and #$0F and #$0F
jmp exit jmp exit
shift: ldx #0 shift: lsr a
lsr a
lsr a lsr a
lsr a lsr a
lsr a lsr a
exit:
.if ::grmode = 9
; Mode 9 mapping ; Mode 9 mapping
exit: .if grmode = 9
; Map colors like this: 0 -> 0, 15 -> 1, 2 -> 3, 3 -> 4 etc. ; Map colors like this: 0 -> 0, 15 -> 1, 2 -> 3, 3 -> 4 etc.
beq @cont beq done9
cmp #15 cmp #15
bne @map bne map9
lda #0 lda #0
@map: add #1 map9: add #1
@cont: .endif done9:
.endif
.if ::grmode = 10
; Mode 10 mapping ; Mode 10 mapping
.if grmode = 10 ; Map out of range colors like this:
; Map out-of-range colors like this:
; 9 -> 8 ; 9 -> 8
; 10 -> 8 ; 10 -> 8
; 11 -> 8 ; 11 -> 8
@@ -558,15 +586,18 @@ exit: .if grmode = 9
; 14 -> 2 ; 14 -> 2
; 15 -> 3 ; 15 -> 3
cmp #9 cmp #9
bcc @cont bcc done10
sub #12 sub #12
bcs @cont bcs done10
lda #8 lda #8
@cont: .endif done10:
.endif ; ::grmode = 10
; Done! ; Done!
ldx #0
rts rts
.endif .endif ; ::ppb = 2
.endproc .endproc
; ****************************************************************************** ; ******************************************************************************
@@ -579,6 +610,41 @@ exit: .if grmode = 9
; ;
; ---------------------------------------------------------------------- ; ----------------------------------------------------------------------
.ifdef USE_CIO_LINE
; position ptr1, ptr2
lda x1
sta OLDCOL
lda x1 + 1
sta OLDCOL + 1
lda y1
sta OLDROW
; plot
jsr SETPIXEL
; position ptr3,ptr4
lda x2
sta COLCRS
lda x2 + 1
sta COLCRS + 1
lda y2
sta ROWCRS
; drawto
ldx griocb
lda #DRAWLN
sta ICCOM,x
lda mask
.if ::grmode = 10
and #$0f
.else
and #colors - 1
.endif
sta ATACHR
jmp CIOV
.else ; USE_CIO_LINE
; locals ; locals
dx := sreg dx := sreg
@@ -797,6 +863,7 @@ end_move:
jmp loop jmp loop
exit: rts exit: rts
.endscope .endscope
.endif ; USE_CIO_LINE
.endproc .endproc
; ****************************************************************************** ; ******************************************************************************
@@ -805,7 +872,8 @@ exit: rts
; ---------------------------------------------------------------------- ; ----------------------------------------------------------------------
; ;
; Clip and draw bar ; Clip and draw bar, this function will disappear when text clipping
; will be done int the TGI kernel
; ;
; ---------------------------------------------------------------------- ; ----------------------------------------------------------------------
@@ -817,10 +885,12 @@ exit: rts
bcs off bcs off
lda x1 + 1 lda x1 + 1
.if >(x_res - 1) > 0
.if >(::x_res - 1) > 0
cmp #>x_res cmp #>x_res
bcc check2 bcc check2
.endif .endif
bne off bne off
lda x1 lda x1
cmp #<x_res cmp #<x_res
@@ -834,10 +904,12 @@ check2: lda y2 + 1
bcs off bcs off
lda x2 + 1 lda x2 + 1
.if >(x_res - 1) > 0
.if >(::x_res - 1) > 0
cmp #>x_res cmp #>x_res
bcc BAR bcc BAR
.endif .endif
bne off bne off
lda x2 lda x2
cmp #<x_res cmp #<x_res
@@ -882,10 +954,12 @@ check2: lda y2 + 1
; Calculate upper right corner ; Calculate upper right corner
lda x2 lda x2
sta x1 sta x1
.if >(x_res - 1) > 0
.if >(::x_res - 1) > 0
lda x2 + 1 lda x2 + 1
sta x1 + 1 sta x1 + 1
.endif .endif
jsr CALC jsr CALC
; Save the values ; Save the values
tya tya
@@ -972,17 +1046,21 @@ skipm: ; Loop while --dy > 0
sta mag_y8 + 1 sta mag_y8 + 1
; Save 8 * mag_x ; Save 8 * mag_x
txa txa
.repeat 3 .repeat 3
asl a asl a
rol mag_x8 + 1 rol mag_x8 + 1
.endrepeat .endrepeat
sta mag_x8 sta mag_x8
; Save 8 * mag_y ; Save 8 * mag_y
tya tya
.repeat 3 .repeat 3
asl a asl a
rol mag_y8 + 1 rol mag_y8 + 1
.endrepeat .endrepeat
sta mag_y8 sta mag_y8
; Done! ; Done!
rts rts
@@ -1007,24 +1085,27 @@ skipm: ; Loop while --dy > 0
ataint: .byte 64,0,32,96 ataint: .byte 64,0,32,96
.bss .bss
rows: .res 1 rows: .res 1
.if >(x_res - 1) > 0
.if >(::x_res - 1) > 0
oldx1: .res 2 oldx1: .res 2
oldx2: .res 2 oldx2: .res 2
.else .else
oldx1: .res 1 oldx1: .res 1
oldx2: .res 1 oldx2: .res 1
.endif .endif
oldy1: .res 1 oldy1: .res 1
oldy2: .res 1 oldy2: .res 1
inv: .res 1 inv: .res 1
.code .code
; Don't draw zero sized characters ; Don't draw zero sized characters
lda mag_x lda mag_x
beq @exit ora mag_y
lda mag_y bne not0
bne @cont rts
@exit: rts
@cont: ; Save string address, ptr3 is needed by BAR not0: ; Save string address, ptr3 is needed by BAR
lda ptr3 lda ptr3
sta string sta string
lda ptr3 + 1 lda ptr3 + 1
@@ -1038,14 +1119,15 @@ skipm: ; Loop while --dy > 0
sub #1 sub #1
add x1 add x1
sta x2 sta x2
.if >(x_res - 1) > 0
.if >(::x_res - 1) > 0
lda x1 + 1 lda x1 + 1
adc #0 adc #0
sta x2 + 1 sta x2 + 1
.else .else
lda #0 lda #0
sta x2 + 1 sta x2 + 1
.endif .endif
; Calculate y2 and adjust y1 ; Calculate y2 and adjust y1
dec y1 dec y1
@@ -1079,29 +1161,37 @@ vert: lda x1
sta y2 sta y2
lda #0 lda #0
sta y2 + 1 sta y2 + 1
beq while ; Always jmp while
; Main loop ; Main loop
loop: inc string loop: inc string
bne skiph bne skiph
inc string + 1 inc string + 1
skiph: ; Save coords skiph: ; Save coords
jsr save_text_y bit text_dir
; Draw one character bmi scvert
jsr outchar
; Restore coords
jsr restore_text_y
; End of loop
while: ldy #0
lda (string),y
bne loop ; Check for null character
rts
; -------------------- ldx y1
; Output one character stx oldy1
outchar: ldx y2
stx oldy2
jmp draw
scvert: ldx x1
stx oldx1
ldx x2
stx oldx2
.if >(::x_res - 1) > 0
ldx x1 + 1
stx oldx1 + 1
ldx x2 + 1
stx oldx2 + 1
.endif
; Draw one character
; Convert to ANTIC code ; Convert to ANTIC code
tay draw: tay
rol a rol a
rol a rol a
rol a rol a
@@ -1118,32 +1208,36 @@ outchar:
sta font sta font
lda #0 lda #0
sta font + 1 sta font + 1
.repeat 3 .repeat 3
asl font asl font
rol a rol a
.endrepeat .endrepeat
adc CHBAS adc CHBAS
sta font + 1 sta font + 1
; Save old coords ; Save old coords
bit text_dir bit text_dir
bpl @hor bpl hor
lda y1 lda y1
sta oldy1 sta oldy1
lda y2 lda y2
sta oldy2 sta oldy2
jmp @cont jmp cont
@hor: lda x1 hor: lda x1
sta oldx1 sta oldx1
lda x2 lda x2
sta oldx2 sta oldx2
.if >(x_res - 1) > 0
.if >(::x_res - 1) > 0
lda x1 + 1 lda x1 + 1
sta oldx1 + 1 sta oldx1 + 1
lda x2 + 1 lda x2 + 1
sta oldx2 + 1 sta oldx2 + 1
.endif .endif
; Get glyph pixels ; Get glyph pixels
@cont: ldy #7 cont: ldy #7
; Put one row of the glyph ; Put one row of the glyph
putrow: sty rows putrow: sty rows
lda (font),y lda (font),y
@@ -1167,118 +1261,89 @@ putcol: asl pixels
sta x1 sta x1
next_col: next_col:
; Go to next column ; Go to next column
jsr inc_x ; increase x coords
dec cols
bpl putcol
next_row:
; Go to next row
jsr dec_y
; Restore old values
bit text_dir bit text_dir
bpl @hor bmi vertinc
lda oldy1
sta y1
lda oldy2
sta y2
jmp @cont
@hor: lda oldx1
sta x1
lda oldx2
sta x2
.if >(x_res - 1) > 0
lda oldx1 + 1
sta x1 + 1
lda oldx2 + 1
sta x2 + 1
.endif
; Next row
@cont: ldy rows
dey
bpl putrow
; We're done!
rts
; -------------------------
inc_x: ; increase x coords
bit text_dir
bmi @vert
lda mag_x lda mag_x
add x1 add x1
sta x1 sta x1
bcc @1 bcc L1
inc x1 + 1 inc x1 + 1
@1: lda mag_x L1: lda mag_x
add x2 add x2
sta x2 sta x2
bcc @2 bcc L2
inc x2 + 1 inc x2 + 1
@2: rts jmp L2
@vert: lda y1 vertinc:
lda y1
sub mag_x sub mag_x
sta y1 sta y1
lda y2 lda y2
sub mag_x sub mag_x
sta y2 sta y2
rts L2:
dec cols
; ------------------------- bpl putcol
dec_y: ; decrease y coords next_row:
; Go to next row
bit text_dir bit text_dir
bmi @vert bmi verty
lda y1 lda y1
sub mag_y sub mag_y
sta y1 sta y1
bcs @1 bcs L3
dec y1 + 1 dec y1 + 1
@1: lda y2 L3: lda y2
sub mag_y sub mag_y
sta y2 sta y2
bcs @2 bcs L6
dec y2 + 1 dec y2 + 1
@2: rts L4: jmp L6
@vert: lda x1 verty: lda x1
sub mag_y sub mag_y
sta x1 sta x1
bcs @3 bcs L5
dec x1 + 1 dec x1 + 1
@3: lda x2 L5: lda x2
sub mag_y sub mag_y
sta x2 sta x2
bcs @4 bcs L6
dec x2 + 1 dec x2 + 1
@4: rts L6:
; Restore old values
; -------------------------
save_text_y: ; Save text's height coords
bit text_dir bit text_dir
bmi @vert bpl reshor
ldx y1 lda oldy1
stx oldy1 sta y1
ldx y2 lda oldy2
stx oldy2 sta y2
rts jmp nextrow
@vert: ldx x1 reshor: lda oldx1
stx oldx1 sta x1
ldx x2 lda oldx2
stx oldx2 sta x2
.if >(x_res - 1) > 0
ldx x1 + 1
stx oldx1 + 1
ldx x2 + 1
stx oldx2 + 1
.endif
rts
; ------------------------- .if >(::x_res - 1) > 0
restore_text_y: ; Position to next char lda oldx1 + 1
sta x1 + 1
lda oldx2 + 1
sta x2 + 1
.endif
; Next row
nextrow:
ldy rows
dey
jpl putrow
; Restore coords
bit text_dir bit text_dir
bmi @vert bmi resvert
ldx oldy1 ldx oldy1
stx y1 stx y1
@@ -1301,18 +1366,20 @@ restore_text_y: ; Position to next char
adc x2 + 1 adc x2 + 1
sta x2 + 1 sta x2 + 1
rts jmp while
@vert: ldx oldx1 resvert:
ldx oldx1
stx x1 stx x1
ldx oldx2 ldx oldx2
stx x2 stx x2
.if >(x_res - 1) > 0
.if >(::x_res - 1) > 0
ldx oldx1 + 1 ldx oldx1 + 1
stx x1 + 1 stx x1 + 1
ldx oldx2 + 1 ldx oldx2 + 1
stx x2 + 1 stx x2 + 1
.endif .endif
lda y1 lda y1
sub mag_x8 sub mag_x8
@@ -1327,6 +1394,10 @@ restore_text_y: ; Position to next char
sbc mag_x8 + 1 sbc mag_x8 + 1
sta y2 + 1 sta y2 + 1
; End of loop
while: ldy #0
lda (string),y
jne loop ; Check for null character
rts rts
.endproc .endproc
@@ -1374,9 +1445,9 @@ done: rts
.code .code
tax tax
beq @cont beq cont
lda #32 lda #32
@cont: add p0scr cont: add p0scr
sta SAVMSC + 1 sta SAVMSC + 1
rts rts
.endproc .endproc
@@ -1405,8 +1476,10 @@ CONTROL:
INSTALL: INSTALL:
UNINSTALL: UNINSTALL:
.if pages = 1 .if pages = 1
SETVIEWPAGE: SETVIEWPAGE:
SETDRAWPAGE: SETDRAWPAGE:
.endif .endif
rts rts