First steps in ASM, but I (probably) need some guidance

Page 5/7
1 | 2 | 3 | 4 | | 6 | 7

Par Mirg

Expert (88)

Portrait de Mirg

26-09-2005, 20:55

Heh, well at least the "Does my F700D have two VDPs"-question is solved. Smile

I've got yet another one, though. The VDP tutorial on map.tni.nl says the base port address is stored in addresses 6 and 7 in the BIOS. Why is it stored in both 6 and 7? It's only a one byte address, right?

I wrote a quick program to read out both addresses and show their binary value (modifying the program yet again, making a convert to binary program as my first code turned out to be a good choice) and they both hold "10011000" or $98. Question

Par Mirg

Expert (88)

Portrait de Mirg

26-09-2005, 21:00

HansO: Thanks for the clear explanation. My F700D indeed has a 7 MHz switch as well (which I don't use at all, really). How can I check if my machine has extra memory as well? I do have an memory mapper cartridge that gives me an additional megabyte, but I have no idea what else was modified or how I can find out. Maybe I should bring it to a fair someday and have it examined. Smile

Par HansO

Paladin (672)

Portrait de HansO

26-09-2005, 21:09

Heh, well at least the "Does my F700D have two VDPs"-question is solved. Smile

I've got yet another one, though. The VDP tutorial on map.tni.nl says the base port address is stored in addresses 6 and 7 in the BIOS. Why is it stored in both 6 and 7? It's only a one byte address, right?

I wrote a quick program to read out both addresses and show their binary value (modifying the program yet again, making a convert to binary program as my first code turned out to be a good choice) and they both hold "10011000" or $98. Question
The two addresses are (excerpt from the MSX BIOS listing, page 2)
0006 98 DB 98H ; currrent port address for VDP Data Read
0007 98 DB 98H ; currrent port address for VDP Data Write

The MSX standard requires the next port address to be 1 higher and that gives you 99H!

I do not know of a MSX where byte 6 and 7 were different in the BIOS. But in theory they can be! I have also not seen a MSX 1 with a different port address pair 98H and 99H. Nearly all MSX 1 programs, especially from the UK, would not work on such a machine.

Par sjoerd

Hero (593)

Portrait de sjoerd

27-09-2005, 11:23

Are you really sure? I thought they made the trick with the port bytes in BIOS-ROM because they wanted the possibility to change the ports if needed in future MSX versions.That's true for MSX1/2. But they didn't change them, and since the MSX2+ standard, they can't.

Par Tanni

Hero (556)

Portrait de Tanni

27-09-2005, 11:42

Tanni: Looking at your code, I can only draw one conclusion.. I have a long, looooong way to go. In the last couple of weeks, a lot of code that was wizardry to me makes quite a lot of sense now, so maybe in the future I'll understand yours as well. Smile
Mirg: The way isn't that long as it seems. The code just looks quite impressing because its Turbo Pascal inline code with ASM mnemonics in the comment parentheses. As you work with an assembler program, you need just the contents of these parentheses and maybe some additional EQU instructions to introduce labels like EXPTPL. I never worked with an assembler programm, I just did inline coding in Turbo Pascal.

Let's have a look at the function VPeek, implemented in Turbo Pascal:

FUNCTION VPeek ( address : Integer ) : Byte ;

VAR value : Byte;

BEGIN (* VPeek *)
  Inline
  (
   $2A/address/     (* ld   hl,(address)  *)

   $FD/$2A/>$FCC0/  (* ld   iy,(EXPTBL-1) *)
   $DD/$21/>$004A/  (* ld   ix,RDVRM      *)
   $CD/>$001C/      (* call CALSLT        *)

   $32/value        (* ld   (value),a     *)
  );
  VPeek:=value;
END; (* VPeek *)

It has an integer parameter ''address'' which holds the address of the VRAM memory location to be read. There's a local variable ''value'' to hold the content of that address to pass it to TP. The inline code calls the function CALSLT, which is also provided beneath Turbo Pascal, where the whole 64 KB memory is RAM. CALSLT itself provides an interslot call. (There are two further but specialized routines doing also an interslot call, CALBAS for envoking BASIC and CALLF, call far, which is a shorter but not so general form of CALSLT.) The IX register pair holds the address of the routine to be called, here the RDVRM (read VRAM) routine. The VRAM address to be read by it is provided via HL register pair. I currently don't know why IY must be EXPTBL-1, but EXPTBL holds some values on the status of the slots. As RDVRM returns the byte read, it must be stored in variable ''value'' to pass it to TP. The other routines work quite similar.

The routines without inline code are some frequently used routines in a TP program. The procedure write_at could be faster, -- and I have also coded faster versions of it -- and uses the NAMBAS system variable located at $F922 to compute the VRAM start address of the string to be displayed. NAMBAS holds the start address of the name table, which is the current video screen memory in VRAM. I don't know why they've choosen this name! Maybe because the ''names'' of the characters displayed are there. By altering NAMBAS, you can switch between several screens. The write_at(1,1,blank) in the procedure ClearScreen wipes out the cursor which is located in position 1,1 after a ClrScr call. There's a possibility to switch off the cursor, but it didn't work, so I used that way to get a totally blank screen.

Argh, of course! I completely misunderstood. My bad.

Can you please tell me the reason of your misunderstanding?

Par Mirg

Expert (88)

Portrait de Mirg

27-09-2005, 12:48

Can you please tell me the reason of your misunderstanding?

Heh, I thought that this would actually work:

VDP98: db $98

I couldn't check because I was at work when I typed it, but *of course* that doesn't work. Using VDP98 in instructions like OUT(VDP98) will be translated to something like OUT($C003), and not (as I thought) like OUT($98). Smile

Ah well, it's good to make a lot of mistakes at first. I'll get better eventually. Smile

And thanks for explaning the Pascal-code. I don't quite understand the slots in MSX-memory yet, but the Compass assembler that rturbo kindly sent me has both a memory- and slot-viewer, so I'll go play around with those and the document about MSX-memory mentioned in one of my other threads. Smile

Par Tanni

Hero (556)

Portrait de Tanni

27-09-2005, 13:33

It seems that you have BIOS-ROM enabled because you can call chget and chput directly. So you also can access the port bytes directly. If you use Turbo Pascal, slot 0 and slot 1 are set to RAM, so you must use CALSLT to envoke BIOS routines or even get some data like the port bytes. The CALSLT slows up the program. I should have read your postings more thoroughly.

Par Mirg

Expert (88)

Portrait de Mirg

03-10-2005, 20:58

Everything's going pretty well now. I decided to not program anything or look at other people's code for three days (since Friday evening) and then attempt to write a program that draws a line somewhere on the screen using only How to Program the Z80, the V9938 Technical Databook and an MSX BIOS calls chart as reference.

And I did it! \o/

I just coded what was described in the book, but I ended up with a vdp_write routine that's almost identical to the routine in the VDP tutorial on map.tni.nl. Probably just my brain remembering stuff that I forgot. I used SLA H instead of RLC H, though. I'll have to check, but I think SLA leaves some junk.. Ah well, almost got it right. Tongue

I do have a question about screens, though. What exactly is the difference between screen 4 and 5? They're both Graphic 4 Mode, but with a different LN-bit, right? I keep reading that games in screen 4 are hard as hell to code and fast, while screen 5 should be a stroll through the park to code, but a bit slow. As far as I understand from the V9938 Technical Databook, both screenmodes are pretty much identical, except for that LN-bit (192 / 212 lines). Question

Par Edwin

Paragon (1182)

Portrait de Edwin

03-10-2005, 21:12

You're screen info is not correct. Screen 4 is a pattern mode like screen 2, but with MSX2 color sprites. Screen 5 is a plain 16 colour graphics mode. The 192/212 lines bit is separate and works in every mode.

Par erwinmusik

Master (140)

Portrait de erwinmusik

03-06-2012, 19:20

I pick up these post because it answers a few questions for me.
I read the whole post with crosschecking to Bios Calls and everything. The replies are contructive and a little bit controvers, but that´s ok, there are many points of views for a coder.
Thus I will try a summary and wish comments and corrections if I´m wrong:

two ways of putting text to the console

1. call BIOS - like CHRPUT, POSIT .....
2. use the VDP registers 98h and 99h with OUT (98/99h),A directly - dosn´t matter if with labels or literals
(labels for the ports are the better way to let the code variable and easier readable; if the label name is useful)

All code needs the HL for position and A for the character. The position is easy calculateable; depends on the graphic mode.

In another post I found routines to put a lot of bytes into the VRAM with one BIOS Call:
(comments and questions by me)

ld IY,(FCC1h-1)     ;    System Variable - Slot 0 expanded?  but why -1     ???
 ld IX,LDIRVM        ;    Adress of BIOS CALL 005Ch  - Blocktransfer from memory to VRAM 
 ld DE,NAMTBL      ;    System Variable - where to found?  ?from F3B3h and up depending on screen mode?
 ld HL,TEXT
 ld BC,7
 call 001Ch           ;    BIOS Call CALSLT

TEXT: db "Thanks!"

another way (in he same post):

ld DE,NAMTBL
 ld HL,TEXT
 ld BC,7
 rst 30h                      ; BIOS Call CALLF
 db 80h
 dw LDIRVM
 
TEXT: db "Thanks!"

this uses the RST30h BIOS Call with 3 bytes of data after the rst30h Call
BIOS:

CALLF
 Address  : #0030
Function : Executes an interslot call
Output   : depends on the calling routine
Registers: AF, and the other registers depending on the calling routine
Remark   : The following is the calling sequence:
           RST #30
           DB destination slot (see RDSLT accu)
           DW destination address

The questions are:
ld IY,(FCC1h-1) ; System Variable - Slot 0 expanded? but why -1 ???
ld DE,NAMTBL ; System Variable - where to found? ( ?from F3B3h and up depending on screen mode?)

what are the the reasons to use method one or two?
(except Blocktransfer, but this can be written with own code in method one or two)

If I have code in the C000h area, I guess it dosn´t matter wich way, Page #0 is always present with BIOS.
Proublaby if interslotcalls needs more time?
I plan to use the SFG05 BIOS, wich is also in the 0000h area.
Thus I have to switch Page #0 to Primary 3 all the time I´m in the music BIOS. And in this case I have to use a lot of interslotcalls or switching the Page #0 a lot of time.
Maybe this will be slower execution?

One question left:
If I read the FFFFh "register" and CPL it, I have the real value. Do I have to CPL the value before I´m writing back?
I saw in some code no CPL before......

Page 5/7
1 | 2 | 3 | 4 | | 6 | 7