Jump to content
IGNORED

Lyxass learning project "Paratroopers"


Recommended Posts

Posted (edited)

I've been learning 6502 / Lynx assembler programming by writing the attached simple game project (WIP), using Lyxass assembler.

 

It's been more fun and less painful than I thought :)

 

It might be some use to those just starting or thinking about starting Lynx assembler programming.

 

I would also appreciate some feedback from experienced 6502 ASM programmers on what I'm doing wrong/badly, or suggestions for improving the code.

 

The latest runnable is "para.lnx" attached.

 

image.thumb.png.cf96085ca2679968d3437fe44aec1f65.png

 

Update 2024-07-22: Added title screen, more sound effects, more animation, game over sequence.

 

Update 2024-08-05: More sound effects, more animation, hi-score, difficulty curve, bomber appears when score > 170, some fixes.

 

 

paratroopers.zip

 

para_090.lnx

Edited by jum
update latest version (again)
  • Like 8
  • Thanks 1
Link to comment
Share on other sites

3 minutes ago, jum said:

I've been learning 6502 / Lynx assembler programming by writing the attached simple game project (WIP), using Lyxass assembler.

 

It's been more fun and less painful than I thought :)

 

It might be some use to those just starting or thinking about starting Lynx assembler programming.

 

I would also appreciate some feedback from experienced 6502 ASM programmers on what I'm doing wrong/badly, or suggestions for improving the code.

 

The runnable is "para.o" in the zip.

 

image.thumb.png.cf96085ca2679968d3437fe44aec1f65.png

paratroopers.zip 46.98 kB · 0 downloads

Some note:

 

Withing BEGIN_ZP/END_ZP only the location counter will be advanced.

 

So

 BEGIN_ZP
 dc.b 10
 END_ZP

is the same as

  BEGIN_ZP
  ds 1
  END_ZP

 

So the value "10" will not be stored.

 

SPRSYS cannot be read, instead you need to use the shadow register:

                ; Enable collision  (SPRSYS ($FC92) &= $df)
                LDA SPRSYS
                AND #$DF
                STA SPRSYS

Should be

; Enable collision  (SPRSYS ($FC92) &= $df)
LDA _SPRSYS
AND #$DF
STA SPRSYS
STA _SPRSYS

 

(See INITSUZY macro).

 

Rather use "BIT" instead of "AND"

 

                LDA JOYPAD
                STA joypadValue
                AND #JOY_LEFT                   ; Sets Z flag if result = 0
                BEQ .checkRight                 ; branch if Z = 1 (set by AND)
                ; Rotate anticlockwise

...

.checkRight
                LDA joypadValue                 ; in case A altered above
                AND #JOY_RIGHT
                BEQ .updateSprite               ; AND result = 0
                ; Rotate clockwise

=> 
                LDA JOYPAD
                STA joypadValue
                BIT #JOY_LEFT                   ; Sets Z flag if result = 0
                BEQ .checkRight                 ; branch if Z = 1 (set by AND)
                ; Rotate anticlockwise
...
.checkRight
;;;                LDA joypadValue                 ; in case A altered above
                BIT #JOY_RIGHT
                BEQ .updateSprite               ; AND result = 0
                ; Rotate clockwise

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Next on tables: If possible split tables into lo and hi table. No need to multiply by 2 and incremt index:

                LDA playerAngle                 ; 0 -> 32
                LSR
                LSR                             ; divide by 4 (range 0 -> 8)
                ASL                             ; multi by 2 for table word offset
                TAY
                LDA playerSprPtrs,y
                STA playerSCB + scbFieldImage
                iNY
                LDA playerSprPtrs,y
                STA playerSCB + scbFieldImage + 1
=>
                LDA playerAngle                 ; 0 -> 32
                LSR
                LSR                             ; divide by 4 (range 0 -> 8)
                TAY
                LDA playerSprPtrs_lo,y
                STA playerSCB + scbFieldImage
                LDA playerSprPtrs_hi,y
                STA playerSCB + scbFieldImage + 1

 

"LDA #0, STA .." => "STZ " (unless A is used later)

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Thank you 42bs, that's awesome feedback ! 👍

 

The things you mention (except the SPRSYS thing) are all things I actually wondered about at the time.

 

I know about STZ being 65C02 instruction, but I need to study the other differences to "plain" 6502 opcodes.

 

As a C and C++ programmer, it's hard for me to think in terms of tables instead of structs and arrays and maths operations.

Link to comment
Share on other sites

32 minutes ago, bhall408 said:

I'm so glad somebody did this! (A riff on the old Apple II game Sabotage!)

I have good memories of playing this on an Appie II in 1982 :)

 

  • Like 1
Link to comment
Share on other sites

ZeroPage Homebrew is playing Paratroopers on today's ZPH stream LIVE on Twitch! Hope you can join us!

 

Games:

 

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Latest version:

- Some sound

- Fragments from heli and base explosion

- Troopers attack base and blow it up when 4 or more land on either side of the base

- other things for you to find out :)

 

para.o

  • Like 3
Link to comment
Share on other sites

1 hour ago, Brek Martin said:

Thanks. I guess you just add the 64 byte header to make a lnx file out of it.

I'll have a go today.

 

 

No, it is a .o file not a .lyx file. It needs a loader to become a ROM file:

 

https://github.com/42Bastian/new_bll/blob/master/uloader/readme.md

 

But at least lynxGD can load it directly.

Or use serial upload via uBLL or BLL loader.

Edited by 42bs
Link to comment
Share on other sites

2 hours ago, 42bs said:
cat $BLL_ROOT/uloader/bll.enc para.o > para.lyx
make_lnx -b0 256k para.lyx

 

Attached result.

para.lnx 256.06 kB · 2 downloads

Thanks, it just seems neater. But I don't want to encourage tate mode, which can be defined in that header!

 

I'm still liking it on real Lynx, but I die before long, overrun by the troops on the ground.

Link to comment
Share on other sites

Another update (see para.o file in first post).

 

It is now a complete "game", however it starts off on max difficulty. IN future I will add increasing difficulty.

 

Also note I spent a few minutes trying to produce a .lnx cartridge image, but no luck. This is what I was trying (Windows 11 cmd line):
copy /b bll.enc + para.o para.lyx

make_lnx -b0 256K para.lyx

ERROR: Unrecognised argument (256K)

make_lnx para.lyx

 

ERROR: Could not determine page size, please set via command line

ERROR: (Your file is not of the correct length, it may be corrupted)

 

Which seems to indicate that the copy is not producing the right thing.

 

Link to comment
Share on other sites

Sorry, it is

make_lnx para.lyx -b0 256K

 

USAGE:  make_lnx <infile> (Optional params)
           -o Output filename (Default=<infile>.lnx)
           -m Manufacturer (Default=Atari)
           -r Left/Right (Default=No rotate)
           -g Game name (Default=<infile>.lnx)
           -b0 Bank0 size (Default=Autocalc, options 0K,64K,128K,256K,512K)
           -b1 Bank1 size (Default=0K, options 0K,64K,128K,256K,512K)

 

Edited by 42bs
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Update 2024-08-05: More sound effects, more animation, hi-score, difficulty curve, bomber appears when score > 170, some fixes.

 

It is now a fully playable game.

 

See "para_090.lnx" in the first post.

 

  • Like 1
Link to comment
Share on other sites

26 minutes ago, jum said:

Update 2024-08-05: More sound effects, more animation, hi-score, difficulty curve, bomber appears when score > 170, some fixes.

 

It is now a fully playable game.

 

See "para_090.lnx" in the first post.

 

Not played yet, but how about saving hiscore? ;-)

And nice blue sky with rasters.

Edited by 42bs
  • Like 1
Link to comment
Share on other sites

1 hour ago, 42bs said:

Not played yet, but how about saving hiscore? ;-)

And nice blue sky with rasters.

Could possibly add hiscore save to EEPROM.

HBL interrupt is already used to do the "background" sky and ground, I need to find a nice sky gradient.

 

Don't want to move to far from the Apple II version "feel".

 

Link to comment
Share on other sites

  • 5 weeks later...

  ZeroPage Homebrew is playing Paratroopers on today's ZPH stream LIVE on Twitch! Hope you can join us!

 

Games:

 

 

  • Like 1
Link to comment
Share on other sites

3 hours ago, obschan said:

It could be nice to have a unique sticky to gather all the ZPH updates rather than posting on each separate threads.

 

You bet! You can check out every single past show and upcoming show on my ZPH Schedule.

 

I post on these threads so that the developer and fans of the games are alerted I'm playing their game and when. Usually this results in the developers jump into the chat and answer questions during the live broadcast like Nop90 did for his three games I featured tonight. Plus it alerts people to exclusive updates of games they won't see anywhere else like I had for Star Blader! 🙂

 

Also, @jum while I was playing tonight I wrapped the score past 255 and it started at 0 again with the easy level. I'm sure you're already aware but I thought I'd let you know. It's super fun and looking forward to more updates!

 

- James

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...