|
Post by omegamax on Nov 10, 2015 0:59:47 GMT
As the topic states i'm coding a game to learn z80 and master system hardware and yes i'm a novice when it comes to z80 instruction set.With the help of stan's tutorial and Calindro the author of Emulicious sharing code with me(Thanks Guys)I've started my master system coding journey.Anyway i'll keep updates and code snippets in my own thread if that is ok with the admins,once i'm done coding the game i'll share the source code and assets for others that want to follow in my footsteps.
Screen Shot:
Game: www.megafileupload.com/qr8U/PsychoticBalloon_.sms?pt=JN3vzBC5suEqGROijt39s2vpqJj7ivp0ptpMD27sb5o%3D
I had no diagonal movement yesterday as my code was structured as so
call Do_GetJoyPadInput ld a,(_JoyPadInput) bit 0,a call nz,Do_BalloonNorthMovement ld a,(_JoyPadInput) bit 1,a call nz,Do_BalloonSouthMovement ld a,(_JoyPadInput) bit 2,a call nz,Do_BalloonWestMovement ld a,(_JoyPadInput) bit 3,a call nz,Do_BalloonEastMovement
I've rewrote the code structure with my previous game programming knowledge of 68000 to what you see below. I'm starting to really grasp how z80 works and I'm enjoying it.
Do_Balloon: call Do_GetJoyPadInPut ld a,(_JoyPadInput) and %00001111 ld e,a ld d,0 ld hl,JoyPadDataTable add hl,de ld a,(hl) add a add a ld e,a ld d,0 ld hl,BalloonVelocityDataTable add hl,de ld c,(hl) inc hl ld b,(hl) inc hl ld e,(hl) inc hl ld d,(hl) ld (ix+YObjectFractionalSpeedOffset),c ld (ix+YObjectSpeedOffset),b ld (ix+XObjectFractionalSpeedOffset),e ld (ix+XObjectSpeedOffset),d ret
JoyPadDataTab: .db $00,$01,$02,$00,$03,$04,$05,$00,$06,$07,$08
BalloonVelocityDataTable: ;Null .db $00,$00,$00,$00 ;JoyPadUpPressed .db $00,$ff,$00,$00 ;JoyPadDownPressed .db $00,$01,$00,$00 ;JoyPadLeftPressed .db $00,$00,$00,$ff ;JoyPadLeftAndUpPressed .db $2b,$ff,$00,$ff ;JoyPadLeftPressed .db $20,$01,$00,$ff ;JoyPadRightPressed .db $00,$00,$00,$01 ;JoyPadRight&UpPressed .db $2b,$ff,$00,$01 ;JoyPadRight&DownPressed .db $20,$01,$00,$01
|
|
|
Post by panama on Nov 10, 2015 8:02:41 GMT
Nice job! I hope to see the collisions soon.
|
|
|
Post by Maxim on Nov 10, 2015 13:58:33 GMT
You can use signed numbers and they come out the same thanks to 2's complement, and your table will be easier to read (-1 instead of $ff). Also no need to write $00 when just 0 will do.
It looks almost like you're using 8.8 fixed-point but the data in the table is a bit strange for that? You might also prefer to use a second level of data to give some inertia/acceleration to the movement, I did that for my "ono" game (plus friction) and it seemed to make it very manoeuvrable.
It also looks like you're using some structured data, have a look at WLA DX structs which help you to define the structure of the memory and then generate the necessary offsets.
|
|
|
Post by omegamax on Nov 10, 2015 17:02:27 GMT
Thanks for replying maxim 1:I know about the about 2s compliment -1 versus $ff old habit i guess same with the $00 instead of 0 2:I may use a second table for inertia/acceleration 3:Thank you for the WLA DX advice.
|
|
|
Post by omegamax on Nov 10, 2015 17:10:05 GMT
Nice job! I hope to see the collisions soon. Thanks panama,I'll be coding the collisions very soon.
|
|
|
Post by omegamax on Nov 11, 2015 7:47:06 GMT
You can use signed numbers and they come out the same thanks to 2's complement, and your table will be easier to read (-1 instead of $ff). Also no need to write $00 when just 0 will do. It looks almost like you're using 8.8 fixed-point but the data in the table is a bit strange for that? You might also prefer to use a second level of data to give some inertia/acceleration to the movement, I did that for my "ono" game (plus friction) and it seemed to make it very manoeuvrable. It also looks like you're using some structured data, have a look at WLA DX structs which help you to define the structure of the memory and then generate the necessary offsets. After reading stan's programing thread and considering what you commented on my code. Are you looking for a fight?. 0 compared to $00 or -1 to $ff there the same you yourself use a logical approach that's not needed $38|$40?.As far as I read you and this bock fellow have been doing this for awhile why exactly?
|
|
|
Post by Maxim on Nov 11, 2015 14:19:25 GMT
I'd perhaps wrongly thought you were unaware of the options, but you're welcome to prefer any notation you like. There's always more than one way to do something, and you can write code any way you like - but if you don't like code discussion, maybe don't post code? I'll hold off on any further comment.
|
|
|
Post by omegamax on Nov 11, 2015 22:44:58 GMT
I'd perhaps wrongly thought you were unaware of the options, but you're welcome to prefer any notation you like. There's always more than one way to do something, and you can write code any way you like - but if you don't like code discussion, maybe don't post code? I'll hold off on any further comment. Were getting off the incorrect way,i don't mind you giving advice Maxim on my code(Evidently you're knowledge is beyond myself) it is when you suggest comments as $00 is the same as 0?Who cares really what I'm doing and that goes for my table -1 to $ff you knew what was happening no?
|
|
|
Post by omegamax on Dec 23, 2015 21:38:13 GMT
So I've been playing a lot of Rush N Attack for mame emulator and thought the master system could probably handle this game.So I've started converting the sprites and back round tiles to see what it would look like.I immediately noticed the sprites are to large for master system(the running and knife animation is 3 and 4 tiles wide,but I decided to do the player sprite,the color palette fits nicely for master system.Anyway right after christmas i'll show what I've coded as a tech demo(no scrolling or music I'm aware how to scroll and draw map columns but not touched music as of yet)here is a small code example.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Rush "N" Attack 'Konami' Sega Master System Tech Demo ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Z80 Code ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Do_SoldierIdle: ld (ix+ObjectState),ObjectIdle ld (ix+ObjectAnimationFrame),ObjectRunningFrame2 call Do_ClearObjectDeltas call Do_ObjectKnifeAttack jp HandleObjectsCont2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SoldierWalkRight: ld a,(ix+ObjectState) cp a,SWalkRight jr z,SoldierWalkRightCont ld (ix+ObjectState),SWalkRight call Do_ModObjectAnimation ld (ix+ObjectXDelta),1 ld (ix+ObjectXDeltaSubPixel),0 ld (ix+ObjectFacingDirection),ObjectFacingRight SoldierWalkRightCont: call Do_ObjectTileMapCheck cp a,NonSolid jr z,InitObjectPlatformFall call Do_ObjectKnifeAttack jp HandleObjectsCont ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Do_SoldierWalkLeft: ld a,(ix+ObjectState) cp a,SWalkLeft jr z,SoldierWalkLeftCont ld (ix_ObjectState),SWalkLeft call Do_ModObjectAnimation ld (ix+ObjectXDelta),-1 ld (ix+ObjectXDeltaSubPixel),0 ld (ix_ObjectDacingDIrection),ObjectFacingLeft SoldierWalkLeftCont: call Do_ObjectTileMapCheck cp a,NonSolid jr z,InitObjectPlatformFall call Do_ObjectKnifeAttack jp HandleObjectsCont ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; InitObjectPlatformFall: call Do_InitObjectPlatFormGravity ld (ix+ObjectInAirFlag),1 ld (ix+ObjectState),ObjectJumping call Do_ModObjectAnimation jp HandleObjectsCont ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Do_SoldierJumping: ld a,(ix+ObjectState) cp a,ObjectJumping jr z,SoldierJumpingCont ld (ix+ObjectState),ObjectJumping ld (ix+ObjectInAirFlag),1 call Do_ModObjectAnimation call Do_InitObjectYVelocity ld (ix+ObjectXDelta),0 ld (ix+ObjectXDeltaSubPixel),0 SoldierJumpingCont: jp HandleObjectsCont ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Do_InitObjectYVelocity: ld (ix+ObjectYDelta),-3 ld (ix+ObjectYDeltaSubPixel),128 ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Do_InitObjectPlatFormGravity: ld (ix+ObjectYDelta),-1 ld (ix+ObjectYDeltaSubPixel),96 ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Do_ModObjectAnimation: ld a,(ix+ObjectState) ld e,a ld d,0 push de ld hl,ObjectAnimationResetTable add hl,de ld a,(hl) ld (ix+ObjectAnimationFrameReset),a ld (ix+ObjectAnimationFrame),a ld e,a ld d,0 ld hl,ObjectAnimationFrameCountConstTable add hl,de ld a,(hl) ld (ix+ObjectAnimationFrameCountConst),a pop de ld hl,ObjectAnimationLimitTable add hl,de ld a,(hl) ld (ix+ObjectAnimationFrameLimit),a ld (ix+ObjectAnimationFrameCount),0 ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Do_ClearObjectDeltas ld (ix+ObjectXDelta),0 ld (ix+ObjectXDeltaSubPixel),0 ld (ix+ObjectYDelta),0 ld (ix+ObjectYDeltaSubPixel),0 ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ObjectAnimationLimitTable: .db 4 ;Running Animation Frame Count Limit 1 .db 4 ;Running Animation Frame Count Limit 2 .db 4 ;Running Animation Frame Count Limit 3 .db 4 ;Running Animation Frame Count Limit 4 .db 5 ;Prone Animation Frame Count Limit 1 .db 5 ;Prone Animation Frame Count Limit 2 .db 5 ;Prone Animation Frame Count Limit 3 .db 8 ;Jump Animation Frame Count Limit 1 .db 8 ;Jump Animation Frame Count Limit 2 .db 8 ;Jump Animation Frame Count Limit 3 .db 7 ;Climbing Animation Frame Count Limit .db 10 ;Knife Animation Frame Count Limit .db 12 ;Knife Prone Animation Frame Count Limit .db 14 ;Dying Animation Frame Count Limit
|
|
|
Post by omegamax on Dec 27, 2015 1:20:16 GMT
I've next to add the rest of the top screen and the soldier frames.
|
|