Crap 0.1 first assembly project

Show us what you're working on, (preferably with screenshots).
User avatar
Ast A. Moore
Manic Miner
Posts: 200
Joined: Mon Nov 13, 2017 3:16 pm

Re: Crap 0.1 first assembly project

Post by Ast A. Moore » Wed Jan 10, 2018 2:33 pm

Nomad wrote:
Wed Jan 10, 2018 2:28 pm
sorry for all the questions : if I could figure out how to generate a tap with Zeus I could use that. I still use the Pasmo because its easy to generate the tap, but the problem is unlike zeus I cant see whats going on.
No worries. I suggest you look into emulators that offer built-in debuggers and use assemblers as, well, assembler. I know Fuse and SpecEmu have debuggers built into them. Windows users might chime in with more suggestions.
1 x
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.

User avatar
Seven.FFF
Microbot
Posts: 141
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: Crap 0.1 first assembly project

Post by Seven.FFF » Wed Jan 10, 2018 2:40 pm

Nomad wrote:
Wed Jan 10, 2018 2:28 pm
what you mean, so every time I add a library it 'moves the goalpoasts', sorry for such a dumb quehow can I force the include file to go to a specific memory location?
Yes indeed!

You can force that by having another org at the top of the included file. You can have as many org directives as you like, and they can appear anywhere in the code.

The problem with that is you end up with a sparse memory map. There will be holes between the blocks of code, and your tap file will be bigger than it needs to be, if you save the entire block including the holes.

Also, consider what happens if you hard code an org, but some code below it later grows so big it starts overrunning into the next block.

Writing tap files in Zeus is dead easy, I’ll make an example in a while.
1 x
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
seven-fff.com/blog

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

Re: Crap 0.1 first assembly project

Post by Nomad » Wed Jan 10, 2018 2:42 pm

Ast A. Moore wrote:
Wed Jan 10, 2018 2:33 pm

No worries. I suggest you look into emulators that offer built-in debuggers and use assemblers as, well, assembler. I know Fuse and SpecEmu have debuggers built into them. Windows users might chime in with more suggestions.
Sorry I am being a potato, I use linux and fuse, I just never took the time to look at fuse's menu options. Yea I got the debugger running now with it - thanks for the tip.
0 x

dfzx
Berk
Posts: 45
Joined: Mon Nov 13, 2017 6:55 pm

Re: Crap 0.1 first assembly project

Post by dfzx » Wed Jan 10, 2018 3:09 pm

Nomad wrote:
Wed Jan 10, 2018 2:42 pm
Sorry I am being a potato, I use linux and fuse, I just never took the time to look at fuse's menu options. Yea I got the debugger running now with it - thanks for the tip.
OK, so, scroll the middle column (the disassembly) to address 50000 and tell us what you find there. How does the assembled (and now disassembled) code relate to your main and test ASM files?

The real question is "where does that 'ld a,100' get placed in memory"?
1 x

User avatar
Morkin
Microbot
Posts: 131
Joined: Mon Nov 13, 2017 8:50 am
Location: Bristol, UK

Re: Crap 0.1 first assembly project

Post by Morkin » Wed Jan 10, 2018 5:55 pm

Nomad wrote:
Wed Jan 10, 2018 2:42 pm

Sorry I am being a potato, I use linux and fuse,
Have you tried using Spud?

<gets coat>
1 x

User avatar
RMartins
Microbot
Posts: 165
Joined: Thu Nov 16, 2017 3:26 pm

Re: Crap 0.1 first assembly project

Post by RMartins » Wed Jan 10, 2018 7:17 pm

I believe the problem you are having, is because you do not understand how the instructions are assembled (converted into bytes) and where they go.

To explain it simply, it works like a regular text editor.
If you add something in the middle of a paragraph, the remaining part of the paragraph gets pushed forward, to give space to what you are adding.

The same happens to your code, if you insert some code in between, the reminder as to move forward.

You can force some specific position, by using the ORG directive.
But if you use more than one ORG directive in your code, you risk overlapping some code, without any warning (from PASMO at least).

Another problem that might be passing you on the side, is that while this is hapenning, you keep on jumping to your start address (hardcoded in your BASIC loader), even though your code as moved.

Try something like this to anchor the start address.

Code: Select all

org 50000
	JP	Main		; This is anchored to this exact same place by the previous ORG directive.
	
	; Place your includes here or somewhere else you want them to be
	include "test.asm"

Main:
	nop
	nop
	ld a,50
	call Wiggy
	ret
end Main
Tip it's good practice, if you intend to return to BASIC after execution, to SAVE registers, specially IY, and restore them before returning to BASIC
1 x

User avatar
Spud
Dizzy
Posts: 90
Joined: Sun Nov 12, 2017 8:50 pm

Re: Crap 0.1 first assembly project

Post by Spud » Wed Jan 10, 2018 7:42 pm

Morkin wrote:
Wed Jan 10, 2018 5:55 pm
Nomad wrote:
Wed Jan 10, 2018 2:42 pm

Sorry I am being a potato, I use linux and fuse,
Have you tried using Spud?

<gets coat>
Hey! I resemble that comment!
2 x

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

Re: Crap 0.1 first assembly project

Post by Nomad » Thu Jan 11, 2018 7:36 am

Day 11: 354 days left..


ImagePotato tip:
To enable local labels in Pasmo, you use the command line option --alocal, in the code you start your local labels with the _ character. mmmm nice. This will help with readability.

Well there seems to be some light at the end of the tunnel (hopefully its not an oncoming vehicle :lol: ...)

Once I had the whole 'how does input work in Pasmo, passing values incident reasonably sorted, it opened the door to actually laying out the project in a more manageable manner. (so each file handles one part of the project..)

Besides being more tidy, it helped with testing new routines to see what was faster/slower (without having to go in with a calculator and start totting up t-states)

Also with the ability to use modular code within the project cut down significantly on the errors and enables project wide updates from one location. All good stuff.

The first thing I did was set up the menu system - well a bare bones version that I can build up. At the moment it just cycles through the different screens, each time a key is pressed you get a sound effect before being whisked to the next screen.

Simple stuff but at least it works. Nice thing about this is I can use it again for other projects.

Next is to add the Prak routine into the project, and finish the start screen/attract mode for the game. (the random value will position a graphic on the screen while the computer waits for input from the user.) Need to figure out how to play a ay ditty during this phase also but the Chuntey blogs I think have the answer to that.

In addition to that been looking at the excellent utilities for generating sound on the spectrum. While the games often get a lot of love for the spectrum the utilities are often cracking also. Had a look at soundFX and that was easy to use with the exception that I must have fluffed up the disassembly of the code somehow (see the programming section for that tale of woe.) But for a simple program its great. I think it will be useful once I get the hang of disassembling the code.update: Thanks to r-tape for the fix. This little utility will help me build a library of zaps and farts for the game :lol:

Here is the code adapted from SoundFX so I can use it as a library...
b appears to regulate the length of the sound pulse.

Code: Select all

org 50000

wiggy:
	ld d,100
	ld e,50
	ld b,60
	call soundFXGen

	ld d,90
	ld e,50
	ld b,60
	call soundFXGen

	ld d,80
	ld e,50
	ld b,60
	call soundFXGen

	ld d,70
	ld e,50
	ld b,60
	call soundFXGen

	ld d,60
	ld e,50
	ld b,60
	call soundFXGen

	ld d,50
	ld e,50
	ld b,60
	call soundFXGen

	ld d,40
	ld e,50
	ld b,60
	call soundFXGen

	ld d,30
	ld e,50
	ld b,60
	call soundFXGen

	ld d,20
	ld e,50
	ld b,60
	call soundFXGen

	ld d,10
	ld e,50
	ld b,60
	call soundFXGen

	ld d,1
	ld e,50
	ld b,60
	call soundFXGen

	ld d,255
	ld e,50
	ld b,60
	call soundFXGen

	ret

soundFXGen:
_S1:     push bc
	ld a,($5C48)		; 11T
	srl a
	srl a
	srl a
	set 4,a			; 8T
	out(254),a		; 11T
	ld b,d
_S2:	nop			; 4T
	nop			; 4T
	nop			; 4T
	djnz _S2		; 50021
	res 4,a
	out(254),a		; 11T
	ld b,e
_S3:	nop			; 4T
	nop			; 4T
	nop			; 4T
	djnz _S3		; 50031
	nop
	dec e			; 4T
	inc d			; 4T
	inc e			; 4T
	pop bc			; 10T
	djnz _S1		; 50006
	ret

end wiggy
I would actually like to disassemble the whole program, as I think a few optimisations could be made to make it more efficient. (but that is a project for later, it apparently has no protection scheme and seems a fairly compact program so..)

The other utility I recall being on a cover tape years ago was a tracker to make music on the spectrum 128, When I found out browsing the interwebs that a fellow had written an entire tutorial on this I figured it would be worth my time having a look. Thanks for Hikoki for the pdf hookup.

In other project news - been experimenting with creating a better square highlighter for the chess board. It will be much more simple (just using the flash attribute) so that will save a lot of time especially with the modular code stuff its a much smaller program.

Another routine I am messing around with is a idle timer, if there is no keyboard interaction for a certain amount of time it will switch to the attract mode. But that is just in the planning stages. I am trying to think of games that did this on the spectrum..

Probably a useless feature but little things for little minds haha. Still it might come in handy for a future project.

Stuff that is left to do - create some fancy screen backgrounds for the menus, complete the chessmen sprites (been looking at the archive for chess games on the spectrum and what graphics they used for some inspiration on what is good/crap.)

Finish reading through the Chuntey blogs. I think I could really improve the quality of the game this way.

Thanks to all that gave me comments and suggestions. It helps a lot to hear your ideas and advice. I think you guys are right in that a lot of my problems are not having a clear idea of the platform or how the assembly works. Over time with some effort on my part I think I can get better and avoid the gotcha's so much. Another thing that is obvious is I need to learn the tools much better. Really understanding how to use Fuse for development and Zeus will avoid a lot of problems. Lol while still a potato I think compared to where I started a few weeks back, progress has been made. I hope this time next year I can do lots of self directed learning - That is my main goal to be in a position where I don't need to bother y'all with my wibble haha.
0 x

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

Re: Crap 0.1 first assembly project

Post by Nomad » Thu Jan 11, 2018 10:12 am

Figured y'all might want to have a peek at the tap file - its just flicks through the various dummy menus loading random colours for the paper, border, ink, and also generates some random sounds.

later on will make sure that the colour combinations are visible, and that the sounds are within some parameters. But in fairness it worked out a whole lot better than I thought at first.

https://nofile.io/f/yoHEpkrbxgG/main.tap
0 x

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

Re: Crap 0.1 first assembly project

Post by R-Tape » Thu Jan 11, 2018 10:36 am

No file there.
0 x

Post Reply