Re: A86: buffers (again)


[Prev][Next][Index][Thread]

Re: A86: buffers (again)



Okay, here is my source.

-Ross Palmer (TCPA)
icq#65081425
http://tcpa.calc.org/members/ross
#include "ti86asm.inc"
nolvl 		= _textShadow
selection	= _textShadow+1
menuTop		= _textShadow+2
level		= _textShadow+3	;[1]
number_levels = _textShadow+7
worldvariable = _textShadow+25
skix = _textShadow+12
skiy = _textShadow+14
temp = _textShadow+16
row  = _textShadow+18
temp_search_name	=	_textShadow+38
score  = _textShadow+45

;page $D addresses
INC_AHL   	= $4637
GETB_AHL  	= $46C3
SWAP_RAM7 	= $47F3

screen_light	=   $f700	;next aligned address
screen_dark	 	=	$fc00
int_table		=	$9000 	;table for im 2 interrupt

.org _asm_exec_ram

	nop
	jp ProgStart
	.dw 0
	.dw ShellTitle

ShellTitle:
	.db "New Assembly Program",0

ProgStart:
	call CloseGray
;install grayscale
	ld hl,int_start
	ld de,$f0f0
	ld bc,int_end-int_start
	ldir
	ld hl,int_table
	ld (hl),$f0
	ld de,int_table+1
	inc b
	ldir
	ld a,int_table/256
	ld i,a
	im 2
play:
	ld e,1
	ld d,1
	ld hl,Skier
	call GridPutSprite
	call buffer
	call _pause
	call CloseGray
	ret

clrbuf:
	ld hl,$f200
 	ld bc,1024
 	xor a
 	call Fill
	ld hl,$f800
	ld bc,1024
	xor a
	call Fill
	ret

buffer:		;copies buffer to screen
	call CloseGray
	ld hl,$f200
	ld de,$fc00
	ld bc,1024
	ldir
	ld de,$f800
	ld hl,$ca00
	ldir
	ret

;===========================================================
; GridPutSprite:                       [routine by Dan Eble]
;  Puts an aligned sprite at (E, D), where HL -> Sprite
;===========================================================
; IN : D  = y (0-7 inclusive)
;      E  = x (0-15 inclusive)
;      HL-> sprite
;
; OUT: AF, BC, DE, HL, IX modified
; Current total : 28b/567t (not counting ret)
;===========================================================
GridPutSprite:
 push hl
 pop ix					; ix-> sprite
 srl d          		; de = 128y+x (16 bytes/row, 8 rows)
 rra
 and $80
 or e           		; add x offset (remember x <= 15)
 ld e,a
 push de
 ld hl,$f200            ; hl-> video ram
 add hl,de              ; hl-> video ram + offset
 ld b,8                 ; initialize loop counter
 ld de,$10
 call GPS_Loop
 pop de              ; initialize line increment
 ld hl,$ca00            ; hl-> video ram
 add hl,de              ; hl-> video ram + offset
 ld b,8                 ; initialize loop counter
 ld de,$10            ; initialize line increment
GPS_Loop
 ld a,(ix+0)    		; get byte from sprite
 ld (hl),a      		; put byte on screen
 inc ix         		; move to next byte in sprite
 add hl,de     			; move to next line on screen
 djnz GPS_Loop
 ret

int_start:
    exx
    ex af,af'
    in a,(3)
    bit 3,a
    jr z,no_down_left_bug
    and %11111110
    out (3),a
no_down_left_bug:
    bit 1,a
    jr z,no_swap
    ld hl,grayscale_counter
    inc (hl)
    ld a,(hl)
    cp 3
    ld a,(screen_dark/256)-$80
    jr c,set_video_port
    ld a,(screen_light/256)-$80
    ld (hl),0
set_video_port:
    out (0),a
no_swap:
    jp $3a
int_end:

grayscale_counter: .db 0

CloseGray:
 im 1					;reset interrupt mode for OS
 ld a,$3C				;make sure video mem is active
 out (0),a
clrMem:				;clear video mem and graph mem
 call _clrLCD
clrGrf:				;clear graph mem
 ld hl,_plotSScreen+6
 ld d,h
 ld e,l
 inc de
 ld (hl), 0
 ld bc,1024
 ldir
 ret

Fill:
 ld e,l
 ld d,h
 inc de
 ld (hl),a
 ldir
 ret

Skier:
	.db %00100100
	.db %00100100
	.db %01111110
	.db %01111110
	.db %01100110
	.db %00111100
	.db %00100100
	.db %00100100
	.db %00100100
	.db %00100100
	.db %00000000
	.db %00000000
	.db %00011000
	.db %00100100
	.db %00100100
	.db %00100100

.end