mirror of
https://github.com/cc65/cc65.git
synced 2026-04-21 09:17:52 +00:00
Implementing TGI
git-svn-id: svn://svn.cc65.org/cc65/trunk@1311 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
#
|
||||
# makefile for the TGI graphics kernel
|
||||
#
|
||||
|
||||
.SUFFIXES: .o .s .c
|
||||
|
||||
%.o: %.c
|
||||
@$(CC) $(CFLAGS) $<
|
||||
@$(AS) -g -o $@ $(AFLAGS) $(*).s
|
||||
|
||||
%.o: %.s
|
||||
@$(AS) -g -o $@ $(AFLAGS) $<
|
||||
|
||||
C_OBJS =
|
||||
|
||||
S_OBJS = tgi-kernel.o \
|
||||
tgi_geterror.o \
|
||||
tgi_getmaxx.o \
|
||||
tgi_getmaxy.o \
|
||||
tgi_getxres.o \
|
||||
tgi_getyres.o \
|
||||
tgi_map_mode.o
|
||||
|
||||
|
||||
all: $(C_OBJS) $(S_OBJS)
|
||||
|
||||
clean:
|
||||
@rm -f *~
|
||||
@rm -f $(C_OBJS:.o=.s)
|
||||
@rm -f $(C_OBJS)
|
||||
@rm -f $(S_OBJS)
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 21.06.2002
|
||||
;
|
||||
; Common functions of the tgi graphics kernel.
|
||||
;
|
||||
|
||||
.include "tgi-kernel.inc"
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; Variables
|
||||
|
||||
.bss
|
||||
|
||||
_tgi_drv: .res 2 ; Pointer to driver
|
||||
_tgi_error: .res 1 ; Last error code
|
||||
|
||||
|
||||
.data
|
||||
|
||||
; Jump table for the driver functions.
|
||||
|
||||
tgi_install: jmp $0000
|
||||
tgi_deinstall: jmp $0000
|
||||
tgi_init: jmp $0000
|
||||
tgi_post: jmp $0000
|
||||
tgi_control: jmp $0000
|
||||
tgi_clear: jmp $0000
|
||||
tgi_setcolor: jmp $0000
|
||||
tgi_setpixel: jmp $0000
|
||||
tgi_getpixel: jmp $0000
|
||||
tgi_line: jmp $0000
|
||||
tgi_bar: jmp $0000
|
||||
tgi_circle: jmp $0000
|
||||
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; Setup the TGI driver once it is loaded.
|
||||
|
||||
tgi_setup:
|
||||
lda _tgi_drv
|
||||
sta ptr1
|
||||
lda _tgi_drv+1
|
||||
sta ptr1+1
|
||||
|
||||
ldy #TGI_HDR_JUMPTAB
|
||||
ldx #1
|
||||
|
||||
@L1: lda (ptr1),y
|
||||
sta tgi_install,x
|
||||
iny
|
||||
inx
|
||||
lda (ptr1),y
|
||||
sta tgi_install,x
|
||||
inx
|
||||
cpx #(TGI_HDR_JMPCOUNT*3)
|
||||
bne @L1
|
||||
|
||||
lda #$00
|
||||
sta _tgi_error
|
||||
|
||||
jsr tgi_install ; Call driver install routine
|
||||
|
||||
; jmp tgi_fetch_error
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; Fetch the error code from the driver and place it into the global error
|
||||
; variable.
|
||||
|
||||
tgi_fetch_error:
|
||||
jsr tgi_set_ptr
|
||||
ldy #TGI_HDR_ERROR
|
||||
lda (ptr1),y
|
||||
sta _tgi_error
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; Load the pointer to the tgi driver into ptr1.
|
||||
|
||||
tgi_set_ptr:
|
||||
lda _tgi_drv
|
||||
sta ptr1
|
||||
lda _tgi_drv+1
|
||||
sta ptr1+1
|
||||
rts
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 21.06.2002
|
||||
;
|
||||
; unsigned char __fastcall__ tgi_geterror (void);
|
||||
; /* Return the error code for the last operation. */
|
||||
|
||||
.include "tgi-kernel.inc"
|
||||
|
||||
|
||||
_tgi_geterror:
|
||||
lda _tgi_error
|
||||
rts
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 21.06.2002
|
||||
;
|
||||
; unsigned __fastcall__ tgi_getmaxx (void);
|
||||
; /* Return the maximum x coordinate. The resolution in x direction is
|
||||
; * getmaxx() + 1
|
||||
; */
|
||||
|
||||
.include "tgi-kernel.inc"
|
||||
.export _tgi_getmaxx
|
||||
.import _tgi_getxres
|
||||
.import decax1
|
||||
|
||||
|
||||
_tgi_getmaxx:
|
||||
jsr _tgi_getxres
|
||||
jmp decax1
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 21.06.2002
|
||||
;
|
||||
; unsigned __fastcall__ tgi_getmaxy (void);
|
||||
; /* Return the maximum y coordinate. The resolution in y direction is
|
||||
; * getmaxy() + 1
|
||||
; */
|
||||
|
||||
.include "tgi-kernel.inc"
|
||||
.export _tgi_getmaxy
|
||||
.import _tgi_getyres
|
||||
.import decax
|
||||
|
||||
|
||||
_tgi_getmaxy:
|
||||
jsr _tgi_getyres
|
||||
jmp decax1
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 21.06.2002
|
||||
;
|
||||
; unsigned __fastcall__ tgi_getxres (void);
|
||||
; /* Return the resolution in X direction */
|
||||
|
||||
|
||||
.include "tgi-kernel.inc"
|
||||
.export _tgi_getxres
|
||||
.import ldaxidx
|
||||
|
||||
|
||||
_tgi_getxres:
|
||||
lda _tgi_drv
|
||||
ldx _tgi_drv+1
|
||||
ldy #TGI_HDR_XRES+1
|
||||
jmp ldaxidx
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 21.06.2002
|
||||
;
|
||||
; unsigned __fastcall__ tgi_getyres (void);
|
||||
; /* Return the resolution in Y direction */
|
||||
|
||||
|
||||
.include "tgi-kernel.inc"
|
||||
.export _tgi_getyres
|
||||
.import ldaxidx
|
||||
|
||||
|
||||
_tgi_getyres:
|
||||
lda _tgi_drv
|
||||
ldx _tgi_drv+1
|
||||
ldy #TGI_HDR_YRES+1
|
||||
jmp ldaxidx
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 31.05.2002
|
||||
;
|
||||
; const char* __fastcall__ tgi_map_mode (unsigned char mode);
|
||||
; /* Map tgi mode codes to driver names */
|
||||
;
|
||||
|
||||
.export _tgi_map_mode
|
||||
.import _tgi_mode_table
|
||||
.import return0
|
||||
.importzp tmp1
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; BEWARE: The current implementation of tgi_map_mode does not work with tables
|
||||
; larger that 255 bytes!
|
||||
|
||||
.code
|
||||
|
||||
_tgi_map_mode:
|
||||
sta tmp1 ; Save mode
|
||||
ldy #$00
|
||||
|
||||
@L0: lda _tgi_mode_table,y
|
||||
beq NotFound ; Branch if mode code zero
|
||||
cmp tmp1
|
||||
beq Found
|
||||
|
||||
; Skip the name
|
||||
|
||||
@L1: iny
|
||||
lda _tgi_mode_table,y
|
||||
bne @L1 ; Loop until end marker found
|
||||
iny ; Skip end marker
|
||||
bne @L0 ; Branch always
|
||||
|
||||
; Mode not found
|
||||
|
||||
NotFound:
|
||||
jmp return0
|
||||
|
||||
; Mode found
|
||||
|
||||
Found: tya
|
||||
ldx #>_tgi_mode_table
|
||||
sec ; Account for the mode byte
|
||||
adc #<_tgi_mode_table ; Return pointer to file name
|
||||
rts
|
||||
|
||||
Reference in New Issue
Block a user