Jump to content
IGNORED

[AQUARIUS] Machine Language Programming on the Aquarius


Recommended Posts

What's the best Aquarius assembler workflow workaround on 64 bit windows 7?

I have faced the same issue and switched over to tniASM - Macro Assember
Do not know if this is the the best, but the freeware version seems to do the job well.
There are some minor differences, like setting the start address:

In TASM:


.ORG $E000


tniASM:

ORG $E000



Note the dot?
Most tniASM commands do not use a .dot like TASM but is all in the tniasm.txt manual.

Regs
Martin

You have working examples please? This is always such a struggle to get one thing working.

 

Meanwhile, What do you think we could do with this Lua Z80 emulator with assembler /dissasembler?

https://github.com/robzed/LuaZ80

 

What could we put together for that?

 

 

 

Trying to get that Aquarius man adventure assembled, at least virtual aquarius could see the file this time. But it was no load.

 

Maybe you can see something glaringly wrong with the code

 

 

; File:    PANSCRN.ASM
; Purpose: Panning screen from array-area
; By:      Martin v.d. Steenoven
;          http://www.vdSteenoven.com/aquarius
;
; Use tniasm (supplied with VirtualAquarius) to compile:
; tniasm panscrn.asm
;
CPU Z80         ; switch to Z80 mode
ORG 31000   ; Start address of machinecode
    ; Aquarius with 16K additional memory required
;
; Definitions to make code more readable
; and to make it easier if I want to use a different size background screen
;
COLS: EQU 40 ; Maximum number of columns per screen
ROWS: EQU 22 ; Maximum number of rows per screen
MAXCOL: EQU 167 ; Last column ( 4+ screens )
 
SETSIZE: EQU MAXCOL * ROWS 
      ; total number of characters (or colors)
      ; 22 * 167 equals 3674
     ; used to calculate the beginning of the
      ; color-table ( offset plus SETSIZE )
  
LASTLEFTCOL: EQU MAXCOL - COLS  
      ; There is a total of 167 colums in the background screen,
      ; we can only draw 40 columns per screen, thus the last
      ; column beginning a new screen is 167 - 40 = 127
 
Initialize:
 
 ; Clear the screen and color it black
   ld      b,$20  ; ASCII code for <space>
        ld      hl,$3000 ; start of screen character ram location
        call    $1e59  ; fill screen character ram with spaces.
        ld      b,$70  ; Green on Black color attrib
        call    $1e59  ; set colour attribs.
 
 ; Keyboard instructions
 ld hl, leftstr ; pointer to text "c - left"
 ld de, 13253 ; on screen, 22nd row, 5th col
 ld bc, 8  ; 8 characters
 ldir
 
 ld hl, rightstr ; pointer to text "b - right"
 ld de, 13274 ; on screen, 22nd row, 26th col
 ld bc, 9  ; 8 characters
 ldir
 
 ; Calculate the start address of the array
 ; where the background screen is located.
 ld  hl, (14552) ; ARRTAB
 ld  de, 7  ;
 add hl, de  ; ARRTAB plus 7 is where the screen dump is located
        ld      (offset), HL ; Save the start address at offset
 
mainloop:
 call do_pan  ; show screen
 call AquariusMan ; show man figure
 call keyboard ; check and wait for key
 jr mainloop
 
keyboard:
        ld      bc,$2F60 ; Pause for $2f60 loops (Approx 1.5 second)
        call    $1d4b  ; SLEEPBC - sleep for BC loops.
 
 ld      bc, $efff ; Scan column 4
 in      a,(c)  ; READ KEYBOARD
 bit     4,a
 jr nz, nextkey ; 'c' is not pressed
 
 ; 'c' is pressed, moving to the left
 ld a, $FF  ; Moving right (-1)
 call prep_move ; Prepare the move
 
        cp $FF  ; minus one (-1)
 jr      nz, end_of_key ; Within limits, we can move left
 
    ; Could jump back to keyboard, but
    ; let's check the 'b' while we are here 
nextkey:
 ld      bc, $f7ff ; Scan column 3
 in      a,(c)  ; READ KEYBOARD
 bit     5,a
 jr nz, keyboard ; 'b' is not pressed
 
 ; 'b' is pressed, moving to the right
 ld a, $01  ; Moving right (+1)
 call prep_move ; Prepare the move
 
        cp LASTLEFTCOL + 1 ; upper left last screen 
 jr      z, keyboard ; Over the limit, do not move to the right
 
end_of_key:
 ret
 
prep_move:
        ld hl, move ; Load the address where the movement is stored into HL
        ld (hl), a  ; Next movement stored in A (+1 or -1)
 
        cp 1  ; >+ Are we moving right?
        ld hl, man  ;  |
 ld a, (hl)  ;  | A now contains the AquariusMan status
        jr z, moving_right ; <+ Now jump if we were moving right
 
moving_left:
 bit 7, a  ; Is AquariusMan also facing left? 
 jr nz, move_ok ;
 ld a, $00  ; AquariusMan is temporarily idle, will be set to left #1
 jr move_ok
 
moving_right:
 bit 7, a  ; is AquariusMan also facing right?
        jr z, move_ok
 ld a, $00  ; AquariusMan is temporarily idle, will be set to right #1
 
move_ok:
 ld hl, move ; Location of the AquariusMan status
 add a, (hl)  ; AquariusMan has 2 states for moving left or right
        cp 3  ; did we got over the 2nd state for moving right?
        jr      nz, prep2
 ld a, 1
 
prep2:
        cp -3  ; did we got over the 2nd state for moving left?
        jr      nz, prep3
 ld a, -1
 
prep3:
 ld hl, man
 ld (hl), a  ; Aquarius man facing right or left (+2, +1 or -1, -2)
 
 ld hl, move
        ld a, (xpos) ; read current first column upperleft corner
        add a, (hl)  ; increase or decrease register A depending on the movement
 ret
 
do_pan:
        ld (xpos), A ; store new first column upperleft corner
        call    FirstCol ; Calculate first column in HL
 ex de, hl  ; DE points at start address characters
 ld hl, 12328
 call scrn  ; Write chars to screen
 
        call    FirstCol ; Calculate first column in HL
 ld  de, SETSIZE  ; DATA contains 4+ screens 
 add hl, de  ; HL points at start address colors
 ex de, hl  ; Now DE points at start address colors
 ld  hl, 13352
 Call scrn  ; Write colors to screen
 ret
 
;Draw a man on the screen, just for fun
 
AquariusMan:
        ld a, (man) ; What is the men's current state?
 cp -2
 jr z, man_left2
 cp -1
 jr z, man_left1
 cp 0
 jr z, man_idle
 cp 1
 jr z, man_right1
 
man_right2:
 ld a, 21  ; Man's head facing right #2
 call ShowMan
 ret
 
man_right1:
 ld a, 23  ; Man's head facing right #1
 call ShowMan
 ret
 
man_idle:
 ld a, 19
 call ShowMan
 ret
 
man_left1:
 ld a, 130  ; Man's head facing left #1
 call ShowMan
 ret
 
man_left2:
 ld a, 140  ; Man's head facing left #2
 call ShowMan
 ret
 
ShowMan:
 ld (13108),a ; 12328+20+19*40
 push af  ; >+ store AF register
 ld a, (14132) ;  | the current color at location
 and 15  ;  | make the foreground black, keep background
 ld (14132), a ;  | store the new color combination
 pop af  ; <+ restore AF register
 inc a  ; Man's legs
 ld (13148),a ; 12328+20+20*40
 ld a, (14172) ; the current color at location
 and 15  ; make the foreground black, keep background
 ld (14172), a ; store the new color combination
 ret
 
scrn:
 ld  c, ROWS  ; 22 rows defined in macro
loop1:
 ld b, COLS  ; 40 columns defined in macro
loop2:
 ld a, (de)
 ld (hl), a
 inc hl
 inc de
 djnz loop2  ; B=B-1, jump while not zero
 
 ; End of columns, goto next row
 dec c
        push    hl               ; >+- temporarily store HL
        ld      hl, MAXCOL - COLS ;  | Skip the difference to the start of next row
        add     hl, de   ;  |
        ex      de, hl   ;  |
        pop     hl          ; <+- restore HL
 jr nz, loop1
 ret
 
FirstCol:
 ld  hl, (offset) ; offset address characters
        ld      a, (xpos) ; xpos = first column upperleft corner
        ld      d, $00
        ld      e, a
        add     hl, de  ; 
 ret
 
 
leftstr: 
dw "c - Left"
 
rightstr: 
dw "right - b"
 
xpos:   db     $00  ; first column upperleft corner
move: db $FF  ; -1 = left, 1 = right
man: db $00  ; -2 = left #2, -1 = left #1, 0 = idle, 1 = right #1, 2 = right #2
 
offset: dw $0000  ; start address screendumps
 
 

You have working examples please? This is always such a struggle to get one thing working.

 

Meanwhile, What do you think we could do with this Lua Z80 emulator with assembler /dissasembler?

https://github.com/robzed/LuaZ80

 

What could we put together for that?

 

The bootloader has been compiled with tniAsm, maybe that helps?

 

There are many Z80 emulators available in C, Java.

You can execute the Aquarius ROM within such emulator.

The tricky part is the I/O like sound, keyboard and screen while keeping the Z80 performance.

 

Regs,

Martin

Trying to get that Aquarius man adventure assembled, at least virtual aquarius could see the file this time. But it was no load.

 

Maybe you can see something glaringly wrong with the code

 

I only had a quick look, but I am missing the rom recognization at E000

The Aquarius will not accept the cartridge without a valid ROM recognization

 

Regs,

Martin

Going in circles with this assembler and went looking for other z-80 emulation options, maybe with scripting.

Found Oshonsoft Z-80 Simulator IDE with built in assembler, dissassembler, and BASIC compiler.

30 day trial, and the "Getting Started" six lessons took me about an hour an a half, some instructions don't match the
interface, but everything eventually did what the tutorial expected it to do, filling memory, testing printer ports, getting keyboard input.

compiling a basic program to assembler and assembling it and loading it into the virtual Aquarius and getting it to scream bloody ?SN ERROR!

 

 

It's Alive!

 

I had some fun with this thing, but I better stay on the path of productivity. So have a go at it and give it a review.

You think we could set up an Aquarius simulation and adapt that BASIC compiler? That would make my holiday.

It would probably mean dropping the default Aquarius BASIC, that was the goal in 1984.

 

Anyway, have a look at this software and maybe you'll see some benefit for future Aquarius development.

  • Like 1

You think we could set up an Aquarius simulation and adapt that BASIC compiler? That would make my holiday.

It would probably mean dropping the default Aquarius BASIC, that was the goal in 1984.

As for an attempt on a Basic compiler, Nitrofurano made had a go at it: http://atariage.com/forums/topic/213965-aquarius-stuff-from-boriels-zx-basic-compiler-first-attempt/ Edited by Aquaman

ZX Basic for the Aquarius might be a project Nitrofurano alone can't complete (though I admire this intentions). ZX Basic for the Sega Master System also seems indefinitely stalled.

 

I'm pretty sure the source for both projects is around. Maybe a second pair of eyes would get ZX Basic for the Aquarius farther. I mention the SMS version as the Z80 is a common point.

  • Like 2

I take the latest files from Nitrofurano, and point zbx to it, get a bin file that's 6K smaller than his example ROM, load it into the Virtual Aquarius, reboot.

Nothing. Now what? If I run it with the -d debugger I get 1536 lines of machine code for a 75 line BASIC program.

 

Maybe there's one of two dozen essential files not included?

Or I'm not using the right command line option?

Or its the compiler is broken on 64 bit windows?

 

You guys get a working binary from running zxb.exe example01.bas on the commandline?

Am I doing that wrong?

 

Loved his working example01.rom and hoping to get some working machine code to build so I can try making a 3x3 sprite editor that will run sprite graphics spritely.

 

I don't expect to pick up and use assembler over night, but I do.

 

Oh BTW, Rob Probin of ZedCone LuaZ80 project got back to my inquiry:

 

LuaZ80 is still a work in progress, had to take a break in order to do some stuff on gulpman (http://gulpman.net)

... just been adding a Lua interpreter to it ... (Hey REXpaint guy, you listening?)

Anyway, if you are interested in using LuaZ80, in a bigger project - say emulate the Mattel Aquarius, then I'll help

by completing/bug fixing the Z80 emulator. Whether I can commit to more than that is another matter: I already have a zillion projects running :-)

 

What did you have in mind for graphics display? Would it be possible to add the z80 to LOVE or something for that?

Yeah, I've used Love2D and SDL (1 and 2) ... so those would probably be possible.

Love2D uses Lua5.1, so that might actually cause some problems. Specifically LuaZ80 use gotos, if I remember correctly.
It might be possible to switch Love2D to use LuaJIT which has goto support.

 

LOVE 0.90 released today, LuaJIT by default instead of LUA 5.1

Cool!

 

So if I'm to understand it at this point in the project your Z80 would basically just return some console data for you to know its working?
Yes. There is a debugger in the LuaZ80 project you can step Z80 with, and an unused op-code will print to stdout.

I have some test code I've been using to test op-codes.

The aquarius graphics screen is only 40x25 characters, console output shouldn't be a problem faking graphics for a while.
Sure. The debugger uses VT100/ANSI control codes to highlight interesting stuff.

Doing that for a while wouldn't be too bad. Also you could add extra unused op-codes or even patch a screen decode.

You still need to basically model that fake Spectrum in Lua? or you'll load some of the standard non-standard ROM image files?
The plan was standard image files. We have write-protect, so that overcomes the ROM writes to ROM.

As for hardware emulation, I'd not got that far yet. The two options were either Lua code or patch a version of
a current emulator to use LuaZ80 as it's CPU emulator
(I've used and looked at zxsp a lot).

 

Zxsp looks like unix/mac only? What are our options on that front?

Edited by Pset
  • Like 1
  • 8 months later...

Hi, Thank's for your comments, I should receive the cassettes from my mother in a few day's so hopefully it is there. I will check out the Aquarius user site and will have to find an Aquarius again.

Hi Clemeilio, it's been a while since you visited this Forum. Any news on the Aquarius side of things?

  • 8 months later...

how to redefine character set? cannot find memory address.

There is no way to redefine the character set in a stock Aquarius. The character data is stored in a 2K ROM that is not mapped into the Aquarius address space, so there is no memory address to change.

 

I'm in the process of designing an upgrade for the Aquarius which will allow user-defined character graphics. Watch the Intellivision forum for an update; I hope to have something to share within the next two weeks.

  • Like 1

interesting.. Compute-032-01-1983 said

 

The Aquarius can display 256 characters.

This includes a 128-character ASCII set with upper-
and lowercase, and 128 user-programmable char
acters, similar to the redefinable character sets on
the Atari, Commodore 64, VIC-20, and TI-99/4A
computers.

I'm afraid they were mistaken. If you study the Aquarius motherboard, you'll see that all of the Aquarius character data comes from the character generator ROM. Even if its contents were directly accessible to the programmer, it could not be changed, since ROM is (as its name indicates) Read Only Memory. Making even half of the character set user-programmable would have required a much different memory design, and it also would have eaten up a whopping 1K out of the ~1.7K of free RAM that an unexpanded Aquarius has.

 

My upgrade will include dedicated character memory, as well as a larger ROM with a variety of built-in character sets.

  • Like 1

I'm afraid they were mistaken. If you study the Aquarius motherboard, you'll see that all of the Aquarius character data comes from the character generator ROM. Even if its contents were directly accessible to the programmer, it could not be changed, since ROM is (as its name indicates) Read Only Memory. Making even half of the character set user-programmable would have required a much different memory design, and it also would have eaten up a whopping 1K out of the ~1.7K of free RAM that an unexpanded Aquarius has.

 

My upgrade will include dedicated character memory, as well as a larger ROM with a variety of built-in character sets.

 

Ok, where is exactly adress of character set?

Ok, where is exactly adress of character set?

The character set does not have an address. The memory locations within the character matrix (from $3000-$33FF) select the characters which appear on the screen; each location corresponds to one on-screen character. However, the corresponding bitmap data from the character generator ROM is only available to the Aquarius's video controller. This ROM is not assigned an address (and in fact does not even appear on the same bus as the other memory), so its contents are "invisible" to the programmer.

  • Like 1
  • 3 weeks later...

how works Virtual Aquarius option:

Util/Load Binary -- This is useful for assembly language program development.

?

typed source and assembled with sjAsm:

	device zxspectrum128
        ORG #6000
begin
 ld hl,$3400
lp:
 ld (hl),l:inc l:jr nz,lp
 ret;jr $
end
	display /d,end-begin
	savebin "test.bin",begin,end-begin

no effect:(

how works Virtual Aquarius option:

Util/Load Binary -- This is useful for assembly language program development.

?

typed source and assembled with sjAsm:

	device zxspectrum128
        ORG #6000
begin
 ld hl,$3400
lp:
 ld (hl),l:inc l:jr nz,lp
 ret;jr $
end
	display /d,end-begin
	savebin "test.bin",begin,end-begin

no effect:(

RAM above $3FFF is on the expansion bus, so it goes through the code scrambler (which XORs the data bus against the value stored in I/O port $FF). Normally this isn't a problem because data written to RAM also goes through the scrambler, so it is scrambled when written but unscrambled again when read out. However the Virtual Aquarius 'Load Binary' function loads the data directly into RAM, so it will be scrambled when read out.

 

For your code to read correctly the scramble code must be set to 0. One way to do this is POKE 14345 with 0, do a soft reset, hit ctrl-c, then load your code into the now unscrambled RAM.

  • 3 months later...

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