A82: Re: 2 questions
[Prev][Next][Index][Thread]
A82: Re: 2 questions
>what if I wanted to display an 8x8 sprite stored at the bottom of the
program
>like this:
>%01011010
>%10100101
>%11000011
>%10000001
>%10000001
>%11000011
>%10100101
>%01011010
Use the OUTI instruction.
>and what if I wanted to fill the entire screen with a drawong?
Same as above.
I wrote some small functions which might interest you, i meant to release
them but have not gotten around to finishing them yet. I have attahced the
file which is a combined test program and the lib. I have not worked on it
for while, but i think the functions included actually work. So have a look
at it, and if you have question, just send, them. If anyone find these
rutines useful you are welcome to use them in your own program, but please
give me the credit for my work. If people are interested in this i might
release a version of this with more rutines when i get the time.
Dines
PORT_DELAY = $7F3
DATA_PORT = $11
CONTROL_PORT = $10
CUR_COL = $800F
CUR_LINE = $8011
#DEFINE GRAPH_START LD A,$8C \ OUT (2),A \ ROM_CALL(CLEARLCD)
#DEFINE L_DATA(ADDR) LD HL,ADDR \ LD DE,(PROGRAM_ADDR) \ ADD HL,DE
#DEFINE POS(COL,LINE) $100*COL+LINE
#DEFINE DATA_OUT CALL PORT_DELAY \ OUT (DATA_PORT),A
#DEFINE CONTROL_OUT CALL PORT_DELAY \ OUT (CONTROL_PORT),A
#DEFINE DATA_IN CALL PORT_DELAY \ IN A,(DATA_PORT)
#DEFINE CONTROL_IN CALL PORT_DELAY \ IN A,(CONTROL_PORT)
#DEFINE POUTI NEG \ NEG \ NEG \ NEG \ OUTI
#DEFINE PINI NEG \ NEG \ NEG \ NEG \ INI
#DEFINE AIL LD A,5 \ CALL PORT_DELAY \ CONTROL_OUT
#DEFINE AIC LD A,7 \ CALL PORT_DELAY \ CONTROL_OUT
#DEFINE GOTO_LINE OR $80 \ CONTROL_OUT
#DEFINE GOTO_COL OR $20 \ CONTROL_OUT
#DEFINE GOTO_BC LD A,B \ GOTO_COL \ LD A,C \ GOTO_LINE
#DEFINE SETPOS LD A,(CUR_COL) \ CONTROL_OUT \ LD A,(CUR_LINE) \ CONTROL_OUT
#DEFINE GOTOPOS CALL FIND_PIXEL \ SETPOS
#DEFINE INC_LINE LD HL,(CUR_LINE) \ INC (HL)
#DEFINE INC_COL LD HL,(CUR_COL) \ INC (HL)
#DEFINE DEC_LINE LD HL,(CUR_LINE) \ DEC (HL)
#DEFINE DEC_COL LD HL,(CUR_COL) \ DEC (HL)
#INCLUDE "TI82.H"
.ORG 0000
GRAPH_START
L_DATA(TSP1)
LD BC,POS(0,0)
CALL_(BWrite)
L_DATA(TSP3)
LD BC,POS(0,0)
CALL_(BRead)
L_DATA(TSP1)
LD BC,POS(3,7)
CALL_(BWrite)
KL1:
CALL GET_KEY
OR A
JR Z,KL1
L_DATA(TSP2)
LD BC,POS(0,20)
CALL_(BCWrite)
L_DATA(TSP4)
LD BC,POS(0,20)
CALL_(BCRead)
L_DATA(TSP2)
LD BC,POS(3,27)
CALL_(BCWrite)
KL2:
CALL GET_KEY
OR A
JR Z,KL2
L_DATA(TSP1)
LD BC,POS(0,0)
CALL_(BErase)
L_DATA(TSP1)
LD BC,POS(3,7)
CALL_(BErase)
KL3:
CALL GET_KEY
OR A
JR Z,KL3
L_DATA(TSP2)
LD BC,POS(0,20)
CALL_(BCErase)
L_DATA(TSP2)
LD BC,POS(3,27)
CALL_(BCErase)
KL4:
CALL GET_KEY
OR A
JR Z,KL4
L_DATA(TSP3)
LD BC,POS(0,0)
CALL_(BWrite)
L_DATA(TSP4)
LD BC,POS(1,0)
CALL_(BCWrite)
KL5:
CALL GET_KEY
OR A
JR Z,KL5
RET
;----------------------------------------------------------------------------
; BWrite
; Input : HL -> DATA
; B = COL, C = LINE
; Destroys : HL,BC,A
;----------------------------------------------------------------------------
BWrite:
AIL
GOTO_BC
LD A,(HL)
LD B,A
INC HL
LD C,DATA_PORT
BWL1:
POUTI
JR NZ,BWL1
RET
;----------------------------------------------------------------------------
; BCWrite
; Input : HL -> DATA
; B = COL, C = LINE
; Destroys : A,HL,DE
;----------------------------------------------------------------------------
BCWrite:
AIL
GOTO_BC
PUSH BC
LD A,(HL)
LD D,A
INC HL
LD A,(HL)
LD E,A
INC HL
BCWL1:
LD C,DATA_PORT
LD B,E
BCWL2:
POUTI
JR NZ,BCWL2
POP BC
INC B
PUSH BC
GOTO_BC
DEC D
JR NZ,BCWL1
POP BC
RET
;----------------------------------------------------------------------------
; BErase
; Input : HL -> DATA
; B = COL, C = LINE
; Destroys : B,A
;----------------------------------------------------------------------------
BErase:
AIL
GOTO_BC
LD A,(HL)
LD B,A
SUB A
BEL1:
CALL PORT_DELAY
OUT (DATA_PORT),A
DJNZ BEL1
RET
;----------------------------------------------------------------------------
; BCErase
; Input : HL -> DATA
; B = COL, C = LINE
;----------------------------------------------------------------------------
BCErase:
AIL
GOTO_BC
PUSH BC
LD A,(HL)
LD D,A
INC HL
LD A,(HL)
LD E,A
BCEL1:
LD B,E
SUB A
BCEL3:
CALL PORT_DELAY
OUT (DATA_PORT),A
DJNZ BCEL3
POP BC
INC B
PUSH BC
GOTO_BC
DEC D
JR NZ,BCEL1
POP BC
RET
;----------------------------------------------------------------------------
; BRead
; Input : HL -> DATA
; B = COL, C = LINE
; Destroys : HL,BC,A
;----------------------------------------------------------------------------
BRead:
AIL
GOTO_BC
LD A,(HL)
LD B,A
INC HL
LD C,DATA_PORT
CALL PORT_DELAY
IN A,(DATA_PORT)
BRL1:
PINI
JR NZ,BRL1
RET
;----------------------------------------------------------------------------
; BCRead
; Input : HL -> DATA
; B = COL, C = LINE
; Destroys : A,HL,DE
;----------------------------------------------------------------------------
BCRead:
AIL
GOTO_BC
PUSH BC
LD A,(HL)
LD D,A
INC HL
LD A,(HL)
LD E,A
INC HL
BCRL1:
CALL PORT_DELAY
IN A,(DATA_PORT)
LD C,DATA_PORT
LD B,E
BCRL2:
PINI
JR NZ,BCRL2
POP BC
INC B
PUSH BC
GOTO_BC
DEC D
JR NZ,BCRL1
POP BC
RET
TSP1:
.DB 10
.DB %11111111
.DB %11000011
.DB %11000011
.DB %11011011
.DB %11111111
.DB %11111111
.DB %11011011
.DB %11000011
.DB %11000011
.DB %11111111
TSP2:
.DB 2,5
.DB %11111111
.DB %11000011
.DB %11000011
.DB %11011011
.DB %11111111
.DB %11111111
.DB %11011011
.DB %11000011
.DB %11000011
.DB %11111111
TSP3:
.DB 10
.DB 0
.DB 0
.DB 0
.DB 0
.DB 0
.DB 0
.DB 0
.DB 0
.DB 0
.DB 0
TSP4:
.DB 2,5
.DB 0
.DB 0
.DB 0
.DB 0
.DB 0
.DB 0
.DB 0
.DB 0
.DB 0
.DB 0
.END