Jump to content
IGNORED

Mad-Assembler (MADS)


Gury

Recommended Posts

Unary operators:

+ Plus (does nothing)

- Minus (changes sign)

~ Bitwise not (complements all bits)

! Logical not (changes true to false and vice versa)

< Low (extracts low byte)

> High (extracts high byte)

^ High 24bit (extracts high byte)

= Extracts memory bank

: Extracts global variable value

Bitwise not will turn %00000001 to %11111110, not %10000000 (bit reverse) like ascrnet asked :(. I'm not sure if there is a reverse bits function in mads but worst case you can probably create a macro that does this for you. Or maybe tebe can add that functionality.

Edited by ggn
Link to comment
Share on other sites

Oh, sure, I didn't read correctly. Here's one way:


lines	= 8

	org $2000

	.proc mirror_player
	ldx #.len player-1
loop_x	lda player,x
	ldy #8
loop_y	asl
	ror player_mirrored,x
	dey
	bne loop_y
	dex
	bpl loop_x
	rts
	.endp

	.local player
	.byte %00000001
	.byte %00000011
	.byte %00000111
	.byte %00001111
	.byte %00011111
	.byte %00111111
	.byte %01111111
        .byte %11111111
	.endl
	
	.local player_mirrored
	.rept lines
	.byte $00
	.endr
	.endl

Another way would be to use WUDSN's graphics converter, to convert the bitmap directly to the desired format including mirroring without generating any source. But that belongs to another thread.

Link to comment
Share on other sites

:-o thank you very much JAC! for the example!!!!!

 

I was failing to do it, since it had not occurred to me to use a variable with zeros when trying to invert the bits of a byte.

 

so I leave it in my code and it works:

.macro pm_escorpion :sprite
	ldx #12
read_escorpion
	.if :1=1
	lda escorpion_1,x
	.else
	lda escorpion_2,x
	.endif
	ldy #8
mirrored
	asl
	ror player_temp,x
	dey
	bne mirrored
	dex
	bpl read_escorpion
	ldx #00
read_temp	
	lda player_temp,x
	sta VPOSP2+116,x
	inx
	cpx #12
	bne read_temp
.endm

Just a doubt of your second option uses less RAM or more :?

regards

 

Link to comment
Share on other sites

:-o thank you very much JAC! for the example!!!!!

 

I was failing to do it, since it had not occurred to me to use a variable with zeros when trying to invert the bits of a byte.

 

Just a doubt of your second option uses less RAM or more :?

 

regards

IDE would simply create the normal plus the reversed data like you originally did by hand. Whether this requires more or less RAM (in the XEX) than generating the reverse data at runtime depend on many factors (number of sprites, the height of sprites, ...). And after all, it doesn't matter for a normal project.

 

In your case, you could pass the parameters to the subroutine, instead of duplicating the code with the macro.

	mwa #scorpion1 mirror_player.source
	jsr mirror_player
	...

	.proc mirror_player
	ldx #.len player-1
loop_x	lda player,x
source	= *-2
	ldy #8

  • Like 1
Link to comment
Share on other sites

 

IDE would simply create the normal plus the reversed data like you originally did by hand. Whether this requires more or less RAM (in the XEX) than generating the reverse data at runtime depend on many factors (number of sprites, the height of sprites, ...). And after all, it doesn't matter for a normal project.

 

In your case, you could pass the parameters to the subroutine, instead of duplicating the code with the macro.

	mwa #scorpion1 mirror_player.source
	jsr mirror_player
	...

	.proc mirror_player
	ldx #.len player-1
loop_x	lda player,x
source	= *-2
	ldy #8

 

understood thank you very much for the explanation, I will follow your recommendation to not repeat the code. :-D

 

regards

  • Like 1
Link to comment
Share on other sites

?varX = 0

.rept nosprites

:4 .byte >(sprites+14*#*4+?varX*14*4*4)

?varX++

.endr

 

Don't remember about nested repts, but something like this should work..

 

Working example from some code:

 

?cy = 0

.rept ITEM_MATRIX_SIZEY

:ITEM_MATRIX_SIZEX .byte <[screenBuffer1+LINE_SIZE+1+[?cy*3*LINE_SIZE+3*#]]

?cy++

.endr

 

I believe nested repts were added in the last few years, but you should test it.

Edited by NRV
Link to comment
Share on other sites

 

Hi guys,

 

is it possible to run .rept within .rept in order to do something like this?

 

for x,0,nosprites-1
 for y,0,3
  dta (sprites+14*y*4+x*14*4*4) / 256
 next
next
nosprites = 5

.macro m_do_x_y x y
  .echo ,:y
.endm

.macro m_for_y x
  .rept 4
  	m_do_x_y ,#
  .endr

.endm

.rept nosprites
  m_for_y #
.endr

  • Like 3
Link to comment
Share on other sites

@JAC!: Your solution is utterly evil :D

 

It's just the way I used to do it back in ATASM and because typically in inner code is more complex, so I prefer this type of "subroutining".

In MADS the most straightforward translation does not need macro, but only aliasing of # via variables.

	.rept 8
	  ?x=#
	  .rept 4
	    ?y=#
	    dta [sprites+14*?y*4+?x*14*4*4] / 256
	   .endr
	.endr 
  • Like 2
Link to comment
Share on other sites

I have been playing around with BBC Micro code and I have found one handy feature of beebasm compiler (directive) which is called "guard".

So "guard" is coupled with previous "org" and it looks like this:

org $2000
guard $2100
;bla bla code
org $2100
;bla bla data

if your code is so long that compiler reaches $2100 it shows the error that code reached guarded address.

This way it could be possible to prevent code and data overlapping... which sometimes occurs if you are not carefull enough.

 

note: to be honest, this could help me back in the days when I was using orgs very much, but these days i'm usually placing all data after code separated by .align and additional orgs I usually use only when adding rastapictures,g2f or rmt.

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

Sounds like you could simulate "guard $2100" with ert, e.g.:

 

  org $2000
  :257 dta 0
  ert *>$2100 ; Previous block exceeds boundary

Xasm outputs:

 

    ert *>$2100 ; Previous block exceeds boundary
t.asm (3) ERROR: User-defined error

Mads outputs:

 

    ert *>$2100 ; Previous block exceeds boundary
t.asm (3) ERROR: User error
Link to comment
Share on other sites

Sounds like you could simulate "guard $2100" with ert, e.g.:

 

  org $2000
  :257 dta 0
  ert *>$2100 ; Previous block exceeds boundary
Xasm outputs:

 

    ert *>$2100 ; Previous block exceeds boundary
t.asm (3) ERROR: User-defined error
Mads outputs:

 

    ert *>$2100 ; Previous block exceeds boundary
t.asm (3) ERROR: User error

 

And then a simple extension to Xuel's helpful suggestion is to make a 'guard' macro, so it will feel like the Beeb.

 

.macro guard
ert *>:1
.endm
Invoked with : guard $C000
  • Like 4
  • Thanks 1
Link to comment
Share on other sites

  • 2 weeks later...

Just wondering how do people handle strings of text to be put on screen with MADS?

.sb 'Text'

converts to ATASCII codes, which is great, but

.cb 'Text'

does EOR $80 to the last character which is perfect to denote the end, except it is only ASCII and not ATASCII?

IE the capitals don't work.

Is there a simple trick I'm missing to have it do the EOR for ATASCII codes, or am I just approaching things the wrong way?

Thanks!

Link to comment
Share on other sites

Yep, thanks. looks like I'll have to be doing that.

 

On another note, is .align supposed to work to exact bytes rather than just pages? Not that it turns out to be that useful for padding out to 128 byte sectors, but when I was experimenting it seems to behave peculiarity with things like ".align $7f"?

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...