Crap 0.1 first assembly project

Show us what you're working on, (preferably with screenshots).
Post Reply
User avatar
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Crap 0.1 first assembly project

Post by Nomad » Sat Dec 30, 2017 2:58 pm

Well further my resolution for 2018 to spawn my very own crap assembly game I will put my laughable progress here for all to have a chuckle at and hopefully give me a few pointers/obiwan like advice along the way to bring this baby home!

So at the moment I have this...

Image

Mmmm just soak it in... Yes friends, its a chess board. However it needs the chessmen and the pawns. That is the next step, that and fixing the board colour - (needs to be green and white really..) still that is pretty smooth sailing.

In the spirit of crap games, you will need two players, who enter there moves via the keyboard (none of that cursor stuff... well not at the moment anyway..). Because there is no chess computer - no complicated AI, and all that other headache causing stuff. All the 'game' will do is accept user input from the two players, and move the chessmen/pawns about the board, removing the pieces when needed.

That will just require a non-vacant square check, if non-vacant remove the piece from the board and replace with the new piece. pretty simple.

But like a fool I decided to tackle the background first. (well it pretty...)

The assembly code was based of a checker pattern program I found on you tube and abused...

Next task is to create the sprites, then the input, then think about the animation, then the 'rules'. mmmmm will add some more cosmetic fluff like a title bar, infobar at the bottom, to make it less of a cheat i will set the border, paper, in the assembly portion and not the basic boot loader next time also.

This is the listing for my 'project'.. lol this was my first crack at it...

Code: Select all


org 50000
	ld hl, 22528	;start of screen page
	ld a, 4		;set a to 8 (height)
loop:	ld b, 4		;set b to 8 (width)
row1a:  ld (hl), 0	;colour is black block
	inc hl          ;increment hl (screenpos)
	ld (hl), 0      ;colour is black block
	inc hl          ;increment hl (screenpos)
	ld (hl), 0	;colour is black block
	inc hl          ;increment hl (screenpos)
	ld (hl), 0      ;colour is black block
	inc hl          ;increment hl (screenpos)
	ld (hl), 127    ;colour is white block
        inc hl          ;increment hl (screenpos)
        ld (hl), 127    ;colour is white block
        inc hl          ;increment hl (screenpos)
        ld (hl), 127    ;colour is white block
        inc hl          ;increment hl (screenpos)
        ld (hl), 127    ;colour is white block
        inc hl          ;increment hl (screenpos)
        djnz row1a      ;jump row1 if non-zero (b)
        ld b, 4         ;reset b to 16
row1b:  ld (hl), 0      ;colour is black block
        inc hl          ;increment hl (screenpos)
        ld (hl), 0      ;colour is black block
        inc hl          ;increment hl (screenpos)
        ld (hl), 0      ;colour is black block
        inc hl          ;increment hl (screenpos)
        ld (hl), 0      ;colour is black block
        inc hl          ;increment hl (screenpos)
        ld (hl), 127    ;colour is white block
        inc hl          ;increment hl (screenpos)
        ld (hl), 127    ;colour is white block
        inc hl          ;increment hl (screenpos)
        ld (hl), 127    ;colour is white block
        inc hl          ;increment hl (screenpos)
        ld (hl), 127    ;colour is white block
        inc hl          ;increment hl (screenpos)
        djnz row1b      ;jump row1 if non-zero (b)
        ld b, 4         ;reset b to 16
row2a:  ld (hl), 127	;colour is black block
	inc hl          ;increment hl (screenpos)
	ld (hl), 127    ;colour is black block
	inc hl          ;increment hl (screenpos)
	ld (hl), 127	;colour is black block
	inc hl          ;increment hl (screenpos)
	ld (hl), 127    ;colour is black block
	inc hl          ;increment hl (screenpos)
	ld (hl), 0      ;colour is white block
        inc hl          ;increment hl (screenpos)
        ld (hl), 0      ;colour is white block
        inc hl          ;increment hl (screenpos)
        ld (hl), 0      ;colour is white block
        inc hl          ;increment hl (screenpos)
        ld (hl), 0      ;colour is white block
        inc hl          ;increment hl (screenpos)
        djnz row2a      ;jump row1 if non-zero (b)
        ld b, 4         ;reset b to 16
row2b:  ld (hl), 127    ;colour is black block
        inc hl          ;increment hl (screenpos)
        ld (hl), 127    ;colour is black block
        inc hl          ;increment hl (screenpos)
        ld (hl), 127    ;colour is black block
        inc hl          ;increment hl (screenpos)
        ld (hl), 127    ;colour is black block
        inc hl          ;increment hl (screenpos)
        ld (hl), 0      ;colour is white block
        inc hl          ;increment hl (screenpos)
        ld (hl), 0      ;colour is white block
        inc hl          ;increment hl (screenpos)
        ld (hl), 0      ;colour is white block
        inc hl          ;increment hl (screenpos)
        ld (hl), 0      ;colour is white block
        inc hl          ;increment hl (screenpos)
        djnz row2b      ;jump row1 if non-zero (b)
        dec a           ;decrement a
        jr nz, loop     ;jump loop if non-zero (a)
        ret
end 50000
That is ugly and I was ashamed at my lack of a third loop to reduce all those filthy repeated blocks... I had to do something...

Code: Select all

org 50000
	ld hl, 22528	;start of screen page
	ld a, 4		;set a to 8 (height)
loop:	ld b, 4		;set b to 8 (width)
        
row1a:  ld c, 4         ;set c to 4 (square)     
row1aa:  ld (hl), 0	;colour is black block
	inc hl          ;increment hl (screenpos)
        dec c
	djnz row1aa
        ld c, 4
row1ab:	ld (hl), 127    ;colour is white block
        inc hl          ;increment hl (screenpos)
        dec c
        djnz row1ab
        djnz row1a      ;jump row1 if non-zero (b)
        ld b, 4         ;reset b to 16
row1b:  ld (hl), 0      ;colour is black block
        inc hl          ;increment hl (screenpos)
        ld (hl), 0      ;colour is black block
        inc hl          ;increment hl (screenpos)
        ld (hl), 0      ;colour is black block
        inc hl          ;increment hl (screenpos)
        ld (hl), 0      ;colour is black block
        inc hl          ;increment hl (screenpos)
        ld (hl), 127    ;colour is white block
        inc hl          ;increment hl (screenpos)
        ld (hl), 127    ;colour is white block
        inc hl          ;increment hl (screenpos)
        ld (hl), 127    ;colour is white block
        inc hl          ;increment hl (screenpos)
        ld (hl), 127    ;colour is white block
        inc hl          ;increment hl (screenpos)
        djnz row1b      ;jump row1 if non-zero (b)
        ld b, 4         ;reset b to 16
row2a:  ld (hl), 127	;colour is black block
	inc hl          ;increment hl (screenpos)
	ld (hl), 127    ;colour is black block
	inc hl          ;increment hl (screenpos)
	ld (hl), 127	;colour is black block
	inc hl          ;increment hl (screenpos)
	ld (hl), 127    ;colour is black block
	inc hl          ;increment hl (screenpos)
	ld (hl), 0      ;colour is white block
        inc hl          ;increment hl (screenpos)
        ld (hl), 0      ;colour is white block
        inc hl          ;increment hl (screenpos)
        ld (hl), 0      ;colour is white block
        inc hl          ;increment hl (screenpos)
        ld (hl), 0      ;colour is white block
        inc hl          ;increment hl (screenpos)
        djnz row2a      ;jump row1 if non-zero (b)
        ld b, 4         ;reset b to 16
row2b:  ld (hl), 127    ;colour is black block
        inc hl          ;increment hl (screenpos)
        ld (hl), 127    ;colour is black block
        inc hl          ;increment hl (screenpos)
        ld (hl), 127    ;colour is black block
        inc hl          ;increment hl (screenpos)
        ld (hl), 127    ;colour is black block
        inc hl          ;increment hl (screenpos)
        ld (hl), 0      ;colour is white block
        inc hl          ;increment hl (screenpos)
        ld (hl), 0      ;colour is white block
        inc hl          ;increment hl (screenpos)
        ld (hl), 0      ;colour is white block
        inc hl          ;increment hl (screenpos)
        ld (hl), 0      ;colour is white block
        inc hl          ;increment hl (screenpos)
        djnz row2b      ;jump row1 if non-zero (b)
        dec a           ;decrement a
        jr nz, loop     ;jump loop if non-zero (a)
        ret
end 50000
but what happened was this...

Image

Who would have thought that a 3 deep nestled loop would go wrong? :) well I need to look at the code again and try and figure out how i screwed it up..
1 x

User avatar
R-Tape
Site Admin
Posts: 1607
Joined: Thu Nov 09, 2017 11:46 am

Re: Crap 0.1 first assembly project

Post by R-Tape » Sat Dec 30, 2017 3:26 pm

Why not go for a square grid? Most Speccy chess games use tiles (16 x 16 pixels), or even UDGs? (8x8) that'd be easier to use with your chess pieces too. Also remember that attribute 0 means you won't see your sprites! (black PAPER and INK).

Interested to see how this progresses.
0 x

User avatar
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: Crap 0.1 first assembly project

Post by Nomad » Sat Dec 30, 2017 3:35 pm

R-Tape wrote:
Sat Dec 30, 2017 3:26 pm
Why not go for a square grid? Most Speccy chess games use tiles (16 x 16 pixels), or even UDGs? (8x8) that'd be easier to use with your chess pieces too. Also remember that attribute 0 means you won't see your sprites! (black PAPER and INK).

Interested to see how this progresses.
I was hoping to use larger sprites but that might be a big headache, like you say. I tried the 8x8 but that seems a bit on the small side. The 16x16 would be ok and would have enough room on the side for the moves.

You are right about the colour - I realised after I had loaded the paper/border that I should have gone for a green and white board instead. That is what I am doing now is switching the black to green as we speak :)

and done..

Image

Next issue is that weird message printing across the board.. hmmm.

:) after having a look at the rest of the archive it seems it would be a little bit to 'radical' to have a non-square chess board. 16x16 it is . Will fix it tomorrow. Then the fun of creating the sprites for the pieces.
Thanks for the tips.
0 x

User avatar
PROSM
Berk
Posts: 44
Joined: Fri Nov 17, 2017 7:18 pm
Location: Sunderland, England
Contact:

Re: Crap 0.1 first assembly project

Post by PROSM » Sat Dec 30, 2017 4:15 pm

Nomad wrote:
Sat Dec 30, 2017 3:35 pm
Image

Next issue is that weird message printing across the board.. hmmm.
That weird message is from when the program was loaded into memory. It's simply remnants of the screen left from BASIC. To get rid of it, you need to clear the bitmap area of the screen before you draw your board, like this:

Code: Select all

	ld hl,16384
	ld de,16385
	ld bc,6143			; Length of the screen minus one
	ld (hl),0
	ldir				; Clear the screen
The above fills the bitmap area with all zeroes, thus getting rid of the message.

I hope this helps you with the message problem.
1 x
All software to-date

Current Projects:
Currently working on ZX Adventure Designer, which lets one create point-and-click graphic adventures for a 48K Spectrum.

User avatar
Morkin
Manic Miner
Posts: 303
Joined: Mon Nov 13, 2017 8:50 am
Location: Bristol, UK

Re: Crap 0.1 first assembly project

Post by Morkin » Sat Dec 30, 2017 5:00 pm

Nice one - you gotta start somewhere and I remember how happy I was just to get something printed on the screen.

Also part of the fun is improving and debugging your own code, and working out different ways of doing something.
1 x

User avatar
MatGubbins
Manic Miner
Posts: 478
Joined: Mon Nov 13, 2017 11:45 am
Location: Kent, UK

Re: Crap 0.1 first assembly project

Post by MatGubbins » Sat Dec 30, 2017 5:07 pm

Well done and congratulations for getting this far with machine code. World domination will be soon on the list!
1 x
Bomb Munchies Ver1930 17th Nov 2017 (look for the blue download box ) If you get a time-out message and live in the UK then try after 9pm-3am.
Send me a PM and I can email it to you too. Kent, UK

User avatar
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: Crap 0.1 first assembly project

Post by Nomad » Sun Dec 31, 2017 5:50 am

PROSM wrote:
Sat Dec 30, 2017 4:15 pm

That weird message is from when the program was loaded into memory. It's simply remnants of the screen left from BASIC. To get rid of it, you need to clear the bitmap area of the screen before you draw your board, like this:

Code: Select all

	ld hl,16384
	ld de,16385
	ld bc,6143			; Length of the screen minus one
	ld (hl),0
	ldir				; Clear the screen
The above fills the bitmap area with all zeroes, thus getting rid of the message.

I hope this helps you with the message problem.
Thank you fella, that solved the problem.

Got the first screen done also...

Image

Image

I love it when a crap game comes together...
Last edited by Nomad on Sun Dec 31, 2017 6:28 am, edited 1 time in total.
0 x

User avatar
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: Crap 0.1 first assembly project

Post by Nomad » Sun Dec 31, 2017 6:04 am

Morkin wrote:
Sat Dec 30, 2017 5:00 pm
Nice one - you gotta start somewhere and I remember how happy I was just to get something printed on the screen.

Also part of the fun is improving and debugging your own code, and working out different ways of doing something.
In fairness I had a lot of help from blogs, and posts from the forums (WOS and here). Especially the series about the connect four game on youtube. Darryl Sloan https://www.youtube.com/watch?v=1gHlMpO8gqw

I had tried to give z80 a go a few times before and never really got beyond the add, sub, repeat addition stage. It is really surprising how many great sources of information about assembly on the z80 came out and started sharing info in the last 10 years or so.

When I saw what had been done with the graphics engines was another kick in the pants to do something - it was now possible to create games that had the potential to look better than anything that was achievable back in the day. Fair enough it will take time to get to that level but its a good long term goal.

But yea I can't deny when I saw the 'otherwise square shaped' chess board on the screen I was sat with a big grin on my face.
MatGubbins wrote:
Sat Dec 30, 2017 5:07 pm
Well done and congratulations for getting this far with machine code. World domination will be soon on the list!
Can only hope, the plan is once I have the first crap game in the bag, I can use that as the template to create other variants. That is partly why i started with board game - I can use the skeleton for something else easy after and focus on adding on more features. That seems a better approach than going for the equivalent of gift from the gods on a first project haha. More a slow climb of many many crap games getting a little bit better each time. I figure that is more realistic also. I might never have the 'skilz' to make a complicated game but I know I can make a crap game :D and being real - I am never going to get to a place to create a complex game without putting in the work with the crap first :D
0 x

User avatar
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: Crap 0.1 first assembly project

Post by Nomad » Sun Dec 31, 2017 8:14 am

'Music' for the title screen is done. Thank you Beepola that is a cracking little app and it runs just fine on linux with Wine.

Now just need to research how to cobble all these bits together, knock up a loading screen and that is another hurdle crossed. 8-)

I was going to crack on with the graphics but I figured get the tune done first and move on. It's one less thing to do. Plus I can see graphics/sprites being much harder 9 sprites need to be created (will just switch the colour for the different players.

Not sure If I can attach the tap file so you can listen to the little ditty. So I uploaded it to a third party.
https://nofile.io/f/ZnEd5pR56Rg/crapin.tap
0 x

AndyC
Microbot
Posts: 169
Joined: Mon Nov 13, 2017 5:12 am

Re: Crap 0.1 first assembly project

Post by AndyC » Sun Dec 31, 2017 11:39 am

Nomad wrote:
Sun Dec 31, 2017 6:04 am
Can only hope, the plan is once I have the first crap game in the bag, I can use that as the template to create other variants. That is partly why i started with board game - I can use the skeleton for something else easy after and focus on adding on more features. That seems a better approach than going for the equivalent of gift from the gods on a first project haha. More a slow climb of many many crap games getting a little bit better each time. I figure that is more realistic also. I might never have the 'skilz' to make a complicated game but I know I can make a crap game :D and being real - I am never going to get to a place to create a complex game without putting in the work with the crap first :D
That's honestly the best approach. I've seen so many people who start off believing that a few weeks of assembly and their first attempt will be the equivalent of Rainbow Islands and then give up with frustration because they barely get to Pong. Start small and not overly ambitious, know that you will definitely do things which, as you improve, you will look back on as dumb ideas. Each step takes you further along until eventually you're producing things far more complicated than you ever imagined you would do.
1 x

Post Reply