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

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

Par PingPong

Prophet (3339)

Portrait de PingPong

03-06-2012, 19:56

Edwin wrote:

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.

Graphic 4 mode in vdp documentation means screen 5 in basic

Par erwinmusik

Master (140)

Portrait de erwinmusik

04-06-2012, 21:09

Sorry, it's me again, but that does not answer my questions one post before

Par Sonic_aka_T

Enlighted (4130)

Portrait de Sonic_aka_T

05-06-2012, 00:11

I think you meant to do VDP98 EQU $98, in which case it'll translate to OUT($98),r. Of course this is still static, so you might as well have written OUT($98),r directly. If you wish to make the port number variable you'll have to load *from* you label. So, for instance, LD A,(VDP98) | LD C,A | OUTI, which would send one byte from [HL] to port [VDP98].

Par hit9918

Prophet (2858)

Portrait de hit9918

05-06-2012, 07:56

@erwinmusic

port 98 is vram write.
CHRPUT console gives cursor and scroll functionality. I guess it is like 10 times slower.

Once you understand A8/FFFF slot setup and port 98 write, you can forget dealing all the other stuff you posted.

After reading FFFF, CPL the value. That's it, no additional CPL before writing.
To deal the VDP, you could copy the BIOS codes to your c000 area, getting rid of ROM switching issues.
Also these couple of bytes practically teach VDP coding.

The ROM got excessive delays in the loops, you can patch this one for vram write:

ld c,&h98
loop:
outi
jp nz,loop ;outi did decrement b and set flags

It goes at MSX1 VDP speed limit, while OTIR would be too fast.
Note this one got 8bit B as counter, different to bios version.

Par erwinmusik

Master (140)

Portrait de erwinmusik

05-06-2012, 17:58

Thanks hit9918, thats a clear explanation. A8/FFFF is no longer magic to me Big smile

here is my simple code to test these
some questions below

VDAT      EQU       98h
VOUT      EQU       99h
TXTNAM    EQU       0F3B3h
CLS     EQU         00C3h
POSIT   EQU         00h
    	ORG 	0BFF9h   ; C000 - 7
	DB 	0FEh
 	DW 	BEGIN
	DW 	ENDE
	DW 	START    ; execute from the start of the code

BEGIN: 	JP	START

RESERV     DW    0h

START   CALL	CLS
	LD	HL,POSIT                  ; positioning at 0,0
	LD	A,"-"
	CALL	VIOUT
	LD	HL,POSIT+1
	LD	A,"K"
	CALL	VIOUT 
	LD	HL,POSIT+2
	LD	A,":"
	CALL	VIOUT
	CALL 	CHGET		; Keyboard Input
	LD	HL,POSIT+4
	CALL	VIOUT                       ; show Keyboard Input
 
LOOP	CALL BREAKX
	JP	NC,START
                RET			;back to Basic

VIOUT	DI
	PUSH	AF		; save A
  	LD 	A,L
  	OUT 	(VOUT),A
  	LD 	A,64		
  	OR 	H		; set the 6th BIT
  	LD 	A,H
  	OUT 	(VOUT),A
	POP	AF		; get A
	OUT	(VDAT),A
	EI
	RET

I set the Screen to 0 and width to 40, thus I can calculate in 40,24 steps the POSIT
I have set POSIT to fix 0h, that´s the start of the Nametable in the VDP.
If I read the content of the TXTNAM (#F3B3 BASE(0) - SCREEN 0 name table)
it wood be better to be shure where it is, but I can´t calculate with that indirect variable: f.e. (TXTNAM) +40*3 won´t work, I found no way to do this. Question
But the first characater "-" appears on the second position, POSIT is "0" and I thought this was the first position on the screen. Is there anything with the automatic increment in the VDP?

And the CHGET Call prints a white square on the first potiton, that, I guess, I cant hide, because it´s in he BIOS code.
Thus I have to write my own Keyboard handler?
Because I will be independend from the BIOS in Slot 0 (as hit9918 wrote: getting rid of ROM switching issues)

Is my code bullshit or something in the right direction? Question
My plan is a program that reads the MIDI Input from the SFG05 and shows the values on a relativ static screen with no gimmicks for the first time...

Par hit9918

Prophet (2858)

Portrait de hit9918

06-06-2012, 06:16

Previously you did let the assembler calculate stuff. Now it's time to write some calculation code yourself Tongue
With constants the assembler can replace the whole expression with the calculation result, but not with variable stuff. But you still could weasel out of this without multiplication:

ld hl,(TXTNAM)
ld de,40*3 ;hehehe 40*3 is still very constant
add hl,de

But soon you may need to search for real mul codes, when positioning gets variable.

Bug:
LD A,64
OR H ; set the 6th BIT
LD A,H

In the end you just moved H to A.
VDP ended up in wrong mode, read mode. Causes bugs.

ld a,h
and 63
or 64

I hope that's it. The AND will shield bad HL addresses turning into mad VDP modi in upper bits.

There is CHSNS at &h009C , telling whether keyboard buffer empty.
If not empty and then calling CHGET, maybe it does not paint a cursor.
I can't find anything else to turn off the cursor, don't know BIOS details.

Do you need 40 chars for that app? If not, I would go screen 1.
One day one could add some color or put it to screen 2 which can do funky rainbow chars.

Par erwinmusik

Master (140)

Portrait de erwinmusik

06-06-2012, 14:19

Super, Thanks bit9918.
What a stupid mistake, I read the code ten times, but blind for the simple things.

AND 63 is "masking", the lower bits up to the 5th leave as they are, Bit 6,7,8 are zeroed
After that with OR Bit 6 is set for "write"
Cool!

And ADD HL,DE is cool as well, I can EQU some variables with fix positions,
like
VALUEA EQU 40*3 ; fix Position for showing value A in Row 4 first position
VALUEB EQU 40*3+20 ; fix Position for showing value B in Row 4 21th Position
and then
ADD HL,VALUEA

OK, I will take Screen1 and check the rest later.

Is it a good idea to make a second screen memory in the RAM (I think this is known as "buffering")?
write all data in this area and after all processing and writing data make a OTDR of the "buffer" to the VDP.
Thus I don´t have a lot of single out´s and only one Call with DI and EI
(I´ve used this in programming the last years in Blitz Basic 3D - Flip Screen is the instruction)

Par Manuel

Ascended (15554)

Portrait de Manuel

06-06-2012, 21:48

erwinmusik: how many bytes are you going to move from RAM to VRAM and how many times? What is the CPU time needed to do that?

Think about these issues...

Par hit9918

Prophet (2858)

Portrait de hit9918

07-06-2012, 14:44

About DI EI, your VDP functions always end up with enabled interrupts.
Sometimes that EI is not wanted, it makes impossible using the functions in a non-bios slotview.

So I advice to remove DI EI from VDP functions and the program got to set it explicitely before calling VDP functions.
What sounds like more work on the long run may give more clarity/flexibility.
Like a more direct path from music slot view to the screen.

It might be possible that your whole app ends up like:

DI
set music slot
mainloop:
all my stuff in music slot view including vram printing
set bios slot
EI ;let interrupts pass
get some keypress
DI
set music slot
jp mainloop

"OTDR", you want to copy things backwards?
otdr like otir is above speed limit, vram wreck if beam in visible area.

I would do functions like these:

locate:
input H = Y, L = X
calculate address and set vram pointer

printstring:
input hl = string, string is terminated by 0 byte.
print to vram

printnumber:
input hl = 16bit number
print to vram

call these under disabled interrupt conditions.
Done these functions, coding is the sheer luxury compared to every time messing with address calculations.

Par erwinmusik

Master (140)

Portrait de erwinmusik

07-06-2012, 18:35

Thanks a lot, that teaches me for a good structure.

Thus the code have "BIOS Time" I can use some BIOS routines, thats good. f.e. the status of the keyboardbuffer.
But where can I find these buffer?

i found a almost complete list of the MSX variables:
http://www.angelfire.com/art2/unicorndreams/msx/RR-RAM.html
This may interesting:

 This variable is used as a counter by the interrupt handler to control the key repeat rate. F3F8H PUTPNT: DEFW FBF0H  <---  set to zero?
 This variable contains the address of the put position in KEYBUF. F3FAH GETPNT: DEFW FBF0H 
 This variable contains the address of the get position in KEYBUF.  (F3FBH)

Thus I would check the status of the Keyboardbuffer and if Z I take the adress of the buffer and get the first?? value?
Then I flush the buffer? to get shure only the first command has to be processed?
I guess the get position is that what I mean.

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