Re: A86: Lets Help Me Debug And Optimize


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

Re: A86: Lets Help Me Debug And Optimize




> ProgStart:
> 	call _runindicoff
> 	call FastClear
> 	call _Flushallmenus
> 	sub a
> 	ld (NumberCounter),a
> 	call GetString
> 	call PutNumber
> 	call PutDirectionRight

ok so now we CALL a sub function. go down there now

> 
>
;========================================================
> ;= A getkey loop
>
;========================================================
> ;Loop:
> ;	call _getkey
> ;	cp kLeft			;Left
> ;	jr z,Left
> ;	cp kRight			;Right
> ;	jr z,Right
> ;	cp kExit			;Exit
> ;	jr z,Exit
> ;	jr Loop
> 
> Loop:
> halt \ halt \ halt				; wait for the interrupt
> ld a,%01111110		; load the row for the arrow keys
> (bit 0 is 0)
> out (1),a			; tell the port to check
> nop \ nop			; give the port time to check the
> hardware
> in a,(1)			; read the key status
> rra				; move last bit to carry flag
> rra				;
> jr nc,Left			; bit 1 is for left
> rra				; check the next key
> jr nc,Right		; bit 2 is for right
> rra				;
> ld a,%00111111		; load the row for exit (bit 6 is 0)
> out (1),a			; tell the port to check
> nop \ nop			; give the port time to check the
> hardware
> in a,(1)			; read the key status
> bit 6,a			; test the bit for the exit key
> jp nz,Loop	        ; if it's not set, we can loop
> jr Exit			; Exit
> 
> Exit:
> 	ret
> 
> Left:   							;The move it left Loop
> 
> 	ld a, (NumberCounter)		;Load a from memory
> 	cp 0						;see if zero....
> 	jr z,PutDirectionRight		;if so, wait for another
> key/
> 								;Display Right Arrow
> 
> 	call FastClear				;Clear previous phone number
> 	ld a, (NumberCounter)		;Load a from memory
> 	dec a						;Decrement it.
> 	ld (NumberCounter),a		;Save a.
> 
> 	call GetString				;Get the string,
> 	call PutNumber				;Put it on Screen,
> 
> 	ld a, (NumberCounter)
> 	cp 0
> 	jr z,PutDirectionRight
> 	jr PutDirectionBoth 		;Go back to the key loop.
> 
> Right:							;The move it rightLoop
> 
> 	ld a, (NumberCounter)		;Get A from textshadow,
> 	cp 13						;See if 13,
> 	jr z,PutDirectionLeft		;If so, wait for another
> key...
> 
> 	call FastClear				;Clear Screen
> 
> 	ld a, (NumberCounter)		;Restores value of a
> 	inc a						;Increments it
> 	ld (NumberCounter),a		;saves a to textshadow,
> 
> 	call GetString				;Gets the right string,
> 	call PutNumber				;Puts it on screen
> 
> 	ld a, (NumberCounter)
> 	cp 13
> 	jr z,PutDirectionLeft
> 	jr PutDirectionBoth
> 
>
;========================================================
> ;= Puts those nice directional sprite-arrows
>
;========================================================
> 
> PutDirectionLeft:
> 	ld hl,Sprite5
> 	ld d,1
> 	ld e,6
> 	call GridPutSprite
> 	ld hl,Sprite8
> 	ld d,1
> 	ld e,7
> 	call GridPutSprite
> 	jp Loop

ok so now we have called this routine

> PutDirectionRight:
> 	ld hl,Sprite6
> 	ld d,1
> 	ld e,7
> 	call GridPutSprite
> 	ld hl,Sprite7
> 	ld d,1
> 	ld e,6
> 	call GridPutSprite
> 	jp Loop

instead of ret from the inital call you jump back to
loop
then when the exit key is pressed the first call you
make to putdirectionright is returned from then they
have to press exit again to leave the loop part
change that first call putdirectionright to a jp

> PutDirectionBoth:
> 	ld hl,Sprite5
> 	ld d,1
> 	ld e,6
> 	call GridPutSprite
> 	ld hl,Sprite6
> 	ld d,1
> 	ld e,7
> 	call GridPutSprite
> 	jp Loop
> 
>
;========================================================
> ;= Puts whatever hl points to at 15,1, and the
> Sprites
>
;========================================================
> 
> PutNumber:
> 	ld a,1
> 	ld (_penRow),a
> 	ld a,15
> 	ld (_penCol),a
> 	call _vputs
> 
> 	ld e,0
> 	ld d,0
> 	ld hl,Sprite1
> 	call GridPutSprite
> 	ld e,1
> 	ld d,0
> 	ld hl,Sprite2
> 	call GridPutSprite
> 	ld e,14
> 	ld d,0
> 	ld hl,Sprite3
> 	call GridPutSprite
> 	ld e,15
> 	ld d,0
> 	ld hl,Sprite4
> 	call GridPutSprite
> 	ret
> 
>
;========================================================
> ;= Input: A, number of string to return in hl
> ;= Output: String pointed to by hl
> ;= Impact: 74 clock cycles
>
;========================================================
> 
> GetString:
> 	ld hl,PointerTable
> 	sla a
> 	ld e,a
> 	ld d,0
> 	add hl,de
> 	ld e,(hl)
> 	inc hl
> 	ld d,(hl)
> 	ex de,hl
> 	ret
> 
>
;========================================================
> ;= Stores the adresses of the Strings in 2 byte
> words
>
;========================================================
> 
> PointerTable:
> ..dw Number0
> ..dw Number1
> ..dw Number2
> ..dw Number3
> ..dw Number4
> ..dw Number5
> ..dw Number6
> ..dw Number7
> ..dw Number8
> ..dw Number9
> ..dw Number10
> ..dw Number11
> ..dw Number12
> ..dw Number13
> 
>
;========================================================
> ;= The actual string data in null terminated strings
> ;= THESE ARE FICTIONAL PEOPLE
>
;========================================================
> 
> Number0:
> ..db " Bedk, BillyBob: 956-2349",0
> Number1:
> ..db " Bzak, BobBilly: 111-2149",0
> Number2:
> ..db " TownRise, Matt: 784-4567",0
> Number3:
> ..db " Early, Mike: 542-546-5409",0
> Number4:
> ..db " Hearball, Kelly: 900-9007",0
> Number5:
> ..db " Hzechkslovak, Eerie: 569-7852",0
> Number6:
> ..db " Marty, Fred: 167-9654",0
> Number7:
> ..db " Oobleck, Joe: 456-5644",0
> Number8:
> ..db " Person, Nate: 456-4567",0
> Number9:
> ..db " Vayers, Petre: 789-1234",0
> Number10:
> ..db " Worthless, Isaac: 574-3087",0
> Number11:
> ..db " Whiner, Lynsday: 456-7856",0
> Number12:
> ..db " Yelkling, Answer: 132-1111",0
> Number13:
> ..db " Zounds!: The-End",0
> 
> ;==============================
> ;=8,8 B/W Sprite Data
> ;=Copyright 2000, Elliott Back
> ;==============================
> 
> Sprite0:
> 	.db %00000000
> 	.db %00000000
> 	.db %00000000
> 	.db %00000000
> 	.db %00000000
> 	.db %00000000
> 	.db %00000000
> 	.db %00000000
> 
> Sprite1:
> 	.db %00000000
> 	.db %00000000
> 	.db %00000000
> 	.db %00000001
> 	.db %00001110
> 	.db %00000001
> 	.db %00000000
> 	.db %00000000
> 
> Sprite2:
> 	.db %01111100
> 	.db %10000000
> 	.db %10000000
> 	.db %10000000
> 	.db %10000000
> 	.db %10000000
> 	.db %10000000
> 	.db %01000000
> 
> Sprite3:
> 	.db %00111110
> 	.db %00000001
> 	.db %00000001
> 	.db %00000001
> 	.db %00000001
> 	.db %00000001
> 	.db %00000001
> 	.db %00000010
> 
> Sprite4:
> 	.db %00000000
> 	.db %00000000
> 	.db %00000000
> 	.db %10000000
> 	.db %01110000
> 	.db %10000000
> 	.db %00000000
> 	.db %00000000
> 
> Sprite5:
> 	.db %00000000
> 	.db %00100000
> 	.db %01100000
> 	.db %11100000
> 	.db %01100000
> 	.db %00100000
> 	.db %00000000
> 	.db %00000000
> 
> Sprite6:
> 	.db %00000000
> 	.db %00000100
> 	.db %00000110
> 	.db %00000111
> 	.db %00000110
> 	.db %00000100
> 	.db %00000000
> 	.db %00000000
> 
> Sprite7:
> 	.db %00000000
> 	.db %00100000
> 	.db %00000000
> 	.db %10100000
> 	.db %00000000
> 	.db %00100000
> 	.db %00000000
> 	.db %00000000
> 
> Sprite8:
> 	.db %00000000
> 	.db %00000100
> 	.db %00000000
> 	.db %00000101
> 	.db %00000000
> 	.db %00000100
> 	.db %00000000
> 	.db %00000000
> ;==============================
> ;GridPutSprite
> ;  +Puts an aligned sprite at
> ;  (e,d), hl > sprite
> ;==============================
> ; In  D  = y (0-7)
> ;     E  = x (0-15)
> ;     HL = Point to Sprite
> ; Out  AF,BC,DE,HL,IX
> ; Current total  28b,567t
> ;==============================
> 
> GridPutSprite:
> push hl
> pop ix
> srl d
> rra
> and $80
> or e
> ld e,a
> ld hl,$fc00
> add hl,de
> ld b,8
> ld de,$10
> Gps_Loop
> ld a,(ix+0)
> ld (hl),a
> inc ix
> add hl,de
> djnz Gps_Loop
> ret
> 
> FastClear:
>     ld hl,$fc00      ;load video into hl
> 	ld de,1          ;load 1 into de
> 	ld c,64          ;number of vertical lines
>     ld a,%00000000   ;load the blank line into a
>     ld (hl),a        ;draw the clear line
> clear
> 	ld b,16          ;number of horizontal lines
>     ld a,%00000000   ;load next blank line
> clearing
>     add hl,de        ;adds de to hl
>     ld (hl),a        ;load a into hl
>     djnz clearing    ;decrement and jump to clearing
> if not zero
> 	dec c            ;decrease c
> 	ld a,c           ;load c into a
> 	jr nz,clear      ;jump relevant to clear if not
> zero
> 	ret              ;exit the routine
> 
> ..end
>
________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at
> http://www.hotmail.com
> 
> 


__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/