Most basic graphical assembley language game

ASM development for the Commodore 64/128 and Commander X16
Post Reply
RetrogamerRhys
Posts: 21
Joined: Mon Oct 07, 2019 3:35 pm

Most basic graphical assembley language game

Post by RetrogamerRhys » Fri Dec 27, 2019 2:25 pm

I was thinking what would be one of the most basic games a newbie like me could program on the Commodore 64 using assembler with maybe BASIC elements. I was thinking about a Pong clone or maybe a guide the dot to another dot game? Any ideas? Thanks.

EvilSandwich
Posts: 20
Joined: Wed Nov 13, 2019 7:36 am

Re: Most basic graphical assembley language game

Post by EvilSandwich » Fri Dec 27, 2019 5:17 pm

Pretty much the only thing you need to do to make just about any game are two main subroutines:

1) Initializing all the assets. Like how big the paddles are, where the ball starts, how the ball will move before you do anything to the game, etc and telling the game where all these value will be stored in memory.

2) The Main Loop. This where the game runs the majority of the time, waiting for your input. It's literally just an endless loop that just continues forever until something happens, like you telling the paddle to move, the ball hitting the paddle, the ball hitting the walls, etc. As it loops, it'll call different subroutines to check if you did anything or if any status need to be applied.

I'm in the process of writing a dirt simple 2D platforming engine and here's an example from my gravity test version.

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; initializing Physics test position, dot color and first spawn
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

LDX #$02 	;setting high and low byte of spawn
STX $02
LDX #$08
STX $01

LDA #$01 	;setting color

STA ($01),y	;spawning dot


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Main Loop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

mainloop:
JSR gravity
JSR applymomentum ;Empty for now
JSR checkcollision ;Empty for now
JSR readkeys	   ;Empty for now
JMP mainloop
All this does so far is spawn a dot and run it through some conditions.

1) Spawn Dot
2) Start Loop
a. Is it in the air? If yes, make it fall.
b. Was it being moved forward from a previous loop? If yes, push it forward.
c. Did it hit anything? If yes, stop it from moving.
d. Did the player push a button? If yes:
i. What button did they push?
ii. What does that button do?
iii. Do what the button does.
e. Restart Loop with new conditions.

You can literally put anything into the main loop, heck if you're just doing a Demoscene you don't even need a subroutine for accepting user input. But the loop ITSELF needs to be in place. Without it, the program will literally do only ONE THING then exit.

So to summarize: the 100% bare minimum a game needs is two main subroutines.

1) Define "Stuff"
2) Do Stuff, then loop back and do more Stuff.

RetrogamerRhys
Posts: 21
Joined: Mon Oct 07, 2019 3:35 pm

Re: Most basic graphical assembley language game

Post by RetrogamerRhys » Fri Dec 27, 2019 7:03 pm

Hi will the code you published work straight in assembler for producing a dot on the screen? As I am unsure of the memory locations you need to write to in Assembler or POKE in Basic. It would be nice to have a tutorial of how to integrate assembley into Basic programs and how to call assembley subroutines etc. Thanks for the code I will try it.

EvilSandwich
Posts: 20
Joined: Wed Nov 13, 2019 7:36 am

Re: Most basic graphical assembley language game

Post by EvilSandwich » Fri Dec 27, 2019 7:11 pm

Oh good lord no. That's not C64 code at all. The C64 won't know what to do with it.

I just posted it as an example. The subroutines those calls go to aren't even included.

User avatar
akuyou
Posts: 563
Joined: Mon Apr 22, 2019 3:19 am
Contact:

Re: Most basic graphical assembley language game

Post by akuyou » Fri Dec 27, 2019 11:46 pm

I think you're going to be best taking a look at my simple samples... There's a tutorial on how to get a bitmap smiley on the screen here:

https://www.chibiakumas.com/6502/simple ... p#LessonS2

Lesson S11 will add Joypad reading, but the video hasn't been recorded yet!!!
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens

Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809

EvilSandwich
Posts: 20
Joined: Wed Nov 13, 2019 7:36 am

Re: Most basic graphical assembley language game

Post by EvilSandwich » Sat Dec 28, 2019 12:10 am

Oooo, looking forward to the joystick one. I the joystick ports are crazy weird between the player 1 and 2 ports.

Strela_999
Posts: 4
Joined: Sun Dec 29, 2019 8:51 am

Re: Most basic graphical assembley language game

Post by Strela_999 » Tue Dec 31, 2019 2:23 pm

Oh, thanks for the joystick tutorial, I was aiming at coding something for the Master System, but if I can port my stuff on PC, it'd be cool to be able to use a joystick.
Plus, it looks simple enough so that I can do it while writing a market analysis based on some villas for sale in Athens, which I'll have to do by mid February, because work won't understand that I want to code game for a decades-old console!
Last edited by Strela_999 on Fri Jan 17, 2020 4:29 pm, edited 1 time in total.

RetrogamerRhys
Posts: 21
Joined: Mon Oct 07, 2019 3:35 pm

Re: Most basic graphical assembley language game

Post by RetrogamerRhys » Tue Dec 31, 2019 4:36 pm

Does anyone have a tutorial on how to save their work to a 5.25inch disk using a 1541-II Floppy Disk Drive from 64Mon (the assembler I am using). I have a formated disk ready. I do recall reading how use the dsave command but I am unsure. I want to be able to save a PRG file after I've finished coding aswell.
Thanks

Post Reply

Return to “C64 Assembly Programming”