A86: Hello World!(help!)


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

A86: Hello World!(help!)




sendto: assembly-86@lists.ticalc.org

Hello World!,
	I'm trying to learn more assembly than is required to do a 
"Hello World!" program. I am attempting to start by programming 
a simple Lights Out* game. However I have encountered a problem 
with the game and was wondering if you could help me. What would
be the best way to turn off the 'lights'?
	I have had only two ideas. I could FindPixel for the tile 
and 'bit' hl and jr to select a sprite based on the result to 
PutSprite (I'm using the 16*x routine off the 86 central site 
if it matters). The second way is there is a way to NOT! a 16*11
tile to the screen; but I do not understand how do do that (is 
there an easy way to do that with PutSprite?)
Heres what I've gotten so far; using the first way:

;usual code first
;key read, using port 1...the key read will jump to jp to log
;---------------------------------------------------------
;       FIRST COLUMN OF BUTTONS LOG LN X2 COMMA STO
;---------------------------------------------------------
log:				;this corresponds to the Log button
	ld b, 5		;the x coord
 	ld c, 2		;the y coord
	call Detect
	ld c,2		;Findpixel will change c (I did a ld 
				;again instead of push/pop)			
	call PutSprite	;Put sprite stored in (HL) at B, C
	ld a,1		;change the accumilator
	jp Loop		;the beginning of the port read

snip...most of the same for the rest of the keys...

;---------------------------------------------------------
;       BUTTON DETECTION: LOAD ON/OFF SPRITE
;---------------------------------------------------------
Detect:
	ld e,b	;copy the x to so FindPixel will work
	ld d,c	;copy the y to so FindPixel will work
	call FindPixel ;unaltered from 86 central
	bit 1,(hl)	;tests the the top left pixel of the box
	jr nz, nnn
	di		;Do i need to do this?
	call onsprite
	ei
	ret
nnn:
	di
	call offsprite
	ei
	ret
;---------------------------------------------------------
;       SPRITE READING
;---------------------------------------------------------
onsprite:
		ld hl, lon	;lon is the 16*11 sprite state:ON
		ret
offsprite:
		ld hl, loff ;loff the corresponding state being:OFF
		ret
;end program stuff

(don't rip my head off...its only 53 lines of codes and comments
43 shy of the 100 limit suggested; though rather lengthy)
	SHOULD this work? I think so...Does it work? not as 
intended... if you hold down the log button the tile flickers back 
and forth between lon and loff. Did I screw up? Is there something
really obvious that I'm missing? How can I get this to work?

*Theres a java version at my web page for those who do not know what 
Lights Out is, at http://www.geocities.com/TimesSquare/9753/lights.html


______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com


Follow-Ups: