Newbie to learn assembly

Pagina 2/3
1 | | 3

Van Manuel

Ascended (19303)

afbeelding van Manuel

11-11-2011, 23:00

I just heard this stuff is at least already emulated Tongue

Van Sky_hawk

Champion (267)

afbeelding van Sky_hawk

12-11-2011, 12:19

Huey: yes, I should add that, I got serveral emails from some russion guys also about it, The document needs updating, I got some more emails I need to process also, I will try to find the time to do that.

Van anonymous

incognito ergo sum (116)

afbeelding van anonymous

14-11-2011, 05:29

I reverse engineered this stuff myself back when writing the Z80 core for my own emulator (and ClosedMSX). The real name of the register is WZ, not MEMPTR.
Also, I'm pretty sure the "emulation" Manuel speaks of (in openMSX) is lacking.

Van Sky_hawk

Champion (267)

afbeelding van Sky_hawk

14-11-2011, 16:34

GuyverR800: When I've updated the document would you be willing to review this WZ -section?

Van wouter_

Champion (508)

afbeelding van wouter_

14-11-2011, 21:38

Also, I'm pretty sure the "emulation" Manuel speaks of (in openMSX) is lacking.
GuyveR800: I just checked the emulation of memptr/wz in openmsx and it matches the description of the memptr_eng.txt document perfectly. Can you be more specific in what exactly is lacking? Or is something missing in that document? Which version of openmsx did you check (very old versions indeed didn't emulate memptr). Thanks.

Van Vampier

Prophet (2409)

afbeelding van Vampier

15-11-2011, 04:55

I'm not sure where this topic got hi-jacked... but a newbie doesn't really care about undocumented features yet (guyver I'm looking forward to a release of closedmsx)

Van Vampier

Prophet (2409)

afbeelding van Vampier

24-11-2011, 23:34

For openMSX use this TCL script to see what is happening.

set throttle off
after time 4 {set throttle on}

ram_watch add 0xc80c -desc "Y Grid"
ram_watch add 0xc80d -desc "X Grid"
ram_watch add 0xc810 -desc "Char"
ram_watch add 0xc80f -desc "Stick"
ram_watch add 0xc810 -desc "Floor1"
ram_watch add 0xc811 -desc "Floor2"

then compile this.

fname "Project1.rom"
org $4000
dw "AB",init,0,0,0,0,0,0

call game

init: 	ld a,31
		ld (ram.ply_y),a
		ld (ram.ply_x),a
		ld a,0
		ld (ram.ply_jstatus),a
		ld (ram.ply_pattern),a
		ld (ram.ply_jheight),a
		ld a,0xc
		ld (ram.ply_color),a
		ld a,60
		ld (ram.ply_jmax),a
		ld a,1
		ld (ram.ply_ws),a
		ld a,2
		ld (ram.ply_jspeed),a

		call setscr
		call setcol
		call initspr
		call setspr
		
		call game
		
		ret
	
game: 	;ld b,0;the hell
		;ld hl,teststr
.loop:	ld b,1
		;call wait
			
		call getGrid
		call setspr
				
		LD a,0
		CALL  0xD5
		ld (ram.ply_stick),a

		ld a,(ram.ply_stick)
		cp 1
		call z,player_up
		
		ld a,(ram.ply_stick)
		cp 3
		call z,player_right
		
		ld a,(ram.ply_stick)
		cp 5
		call z,player_down
		
		ld a,(ram.ply_stick)
		cp 7
		call z,player_left 

		jp .loop
		ret
		
wait:	;halt
		djnz wait
		RET  		

player_up:	ld a,(ram.ply_y)
			ld b,2
			sub a,b
			ld (ram.ply_y),a
			ret

player_down:ld a,(ram.ply_y)
			ld b,2
			add a,b
			ld (ram.ply_y),a
			ret

player_left:ld a,(ram.ply_x)
			ld b,2
			sub a,b
			ld (ram.ply_x),a
			ret

player_right:ld a,(ram.ply_x)
			ld b,2
			add a,b
			ld (ram.ply_x),a
			ret


getGrid:;translate y and x to an 8x8 grid
		ld a,(ram.ply_y) ; div Y by 8
		srl a	; div by 2
		srl a	; div by 2
		srl a	; div by 2
		add a,1 ; add 1
		ld (ram.grid_y),a
	
		ld a,(ram.ply_x)	; div X by 8
		srl a ; div by 2
		srl a ; div by 2
		srl a ; div by 2
		ld (ram.grid_x),a	
		
		ld a,(ram.grid_y) ; then do y*32+x
		ld l,a
		ld h,0
		sla l
		rl h
		sla l
		rl h
		sla l
		rl h
		sla l
		rl h
		sla l
		rl h

		ld a,(ram.grid_x)
		ld c,a
		ld b,0
		add hl,bc
		ld (ram.grid_y),hl
		
		ld a,(ram.grid_y)
		ld (ram.Grid_ScanY),a

		ld a,(ram.grid_x)
		ld (ram.Grid_ScanX),a
		
		ld hl,(ram.Grid_ScanY)
		ld bc,0x20
		add hl,bc
		
		ld bc,0x1800
		add hl,bc
		
		;scan tile 1
		call scangrid
		
		ld (ram.ply_floor1),a
	
		;add 1 to the chan address
		ld bc,0x01
		add hl,bc
	
		;scan tile 2	
		call scangrid
		
		ld (ram.ply_floor2),a
		
		ret
				
scangrid:
		;add 0x1800 to get the right stuff

		ld (ram.Grid_ScanY),hl
		
		CALL  0x4a
		ld b,a
		
		ld a,98
		call 0x4d
		halt
		
		ld a,b
		call 0x4d
		
		;halt
		
		CALL  0x4a	
		ld (ram.grid_chr),a
		ret 
;-------------------------------------------
;init graphics and sprites
;-------------------------------------------

setscr:		;CALL   0x41 		;SCREEN OFF

			LD a,0				;disable keyclick
			LD (0xf3db),a

			CALL   0x72			;switch to screen 2
			LD    HL,15+1024	;color 15,1,1
			LD    (0xF3E9),HL
			XOR   A
			LD    (0xF3EB),A
			CALL   0x62 		;Set color
			
			LD    A,1			; let me type in screen2
			LD    (0xFCB0),A
			LD    (0xFCAF),A
			LD    A,32			; 32 columns text mode
			LD    (0XF3B0),A

			;init screen2 for screen1 like use
			LD HL,0x00       	; VRAM start
			CALL SETVDP			; INIT VDP

			XOR   A				; CLS
			CALL  0xC3 			
			CALL  0x69 			; CLEAR sprS
				
			LD de,776+(0*2048)	; load fonts
			CALL  initfnt
			LD de,776+(1*2048)
			CALL  initfnt
			LD de,776+(2*2048)
			CALL  initfnt
			CALL  0x44 			; SCREEN ON
			
			CALL  0x41			;set screen off
			XOR a
			CALL  0xC3 			;CLS
			LD HL,FIELD0		;Intro Screen
			CALL print
			CALL  0x44			;set screen on
			
			ld hl,0x0a0a
			ld a,101
			call 0x4d
		
			RET

initfnt: 	LD bc,40
			LD HL,font
			CALL  $5c
			RET
		 
initcol: 	LD bc,40
			LD HL,colors
			CALL $5c
			RET	
			
initspr: 		ld	a,11100110b
				di
				out	(0x99),a
				ld	a,1+128
				ei
				out	(0x99),a
			
			LD de,0x3800 
			LD bc,32
			LD HL,sprite
			CALL $5c
			ret
						
setspr: 	ld de,0x1b00
			ld bc,4
			ld hl,ram.ply_y
			CALL $5c			
			RET				
			
SETVDP:		LD A,L
			DI
			OUT (0x99),A
			LD A,H
			AND 0x3f
			OR 0x40
			OUT (0x99),A
			EI
			RET


			
SETCOL: 	LD    A,0xF0		; set colors
			LD    BC,2048
			LD    HL,0x2000
			CALL   0x56
			LD    A,0xF0
			LD    BC,2048
			LD    HL,0x2800
			CALL   0x56
			LD    A,0xF0
			LD    BC,2048
			LD    HL,0x3000
			CALL   0x56
		
			LD de,8192+776+(0*2048) ;load colors for fonts
			CALL  initcol
			LD de,8192+776+(1*2048)
			CALL  initcol	
			LD de,8192+776+(2*2048)
			CALL  initcol	
			
			RET
			
PRINT:		LD A,(HL)
			INC HL
			AND A
			RET Z
			CALL  0xA2 
			JR PRINT
			RET
			
		  ;01234567
Font: 	DB 00000000b
		DB 11111011b ;a
		DB 11111011b
		DB 11111011b
		DB 00000000b		
		DB 11111111b
		DB 01111111b
		DB 01111111b


		DB 01010101b ;b
		DB 11111111b
		DB 11111111b
		DB 11111111b		
		DB 11111111b
		DB 11111111b
		DB 11111111b
		DB 11111111b
		
		DB 11111111b ;c
		DB 11111111b
		DB 11111111b
		DB 11111111b		
		DB 11111111b
		DB 11111111b
		DB 11111111b
		DB 01010101b
		
		DB 11111111b ;d
		DB 11111111b
		DB 11111111b
		DB 11111111b		
		DB 11111111b
		DB 11111111b
		DB 11111111b
		DB 01010101b
		
		DB 01010101b ;e
		DB 10101010b
		DB 01010101b
		DB 10101010b
		DB 01010101b
		DB 10101010b
		DB 01010101b
		DB 10101010b
	
colors: DB 0x00
		DB 0x45
		DB 0x57
		DB 0x7e
		DB 0x00
		DB 0x45
		DB 0x57
		DB 0x7e
		
		DB 0x54
		DB 0x75
		DB 0xe6
		DB 0xfe
		DB 0xfe
		DB 0xfe
		DB 0xfe
		DB 0xfe

		DB 0xfe
		DB 0xfe
		DB 0xfe
		DB 0xfe
		DB 0xe7
		DB 0x75
		DB 0x54
		DB 0x40
		
		DB 0xfe
		DB 0xfe
		DB 0xfe
		DB 0xfe
		DB 0xe7
		DB 0x75
		DB 0x54
		DB 0x40
		
		DB 0x60
		DB 0x80
		DB 0x90
		DB 0xa0
		DB 0xb0
		DB 0xe0
		DB 0xf0
		DB 0xf0
		
		   ;12345678
sprite: DB 10111101b
		DB 11011011b
		DB 01010111b
		DB 10101100b
		DB 11010011b
		DB 11101011b
		DB 01110011b
		DB 00001100b
		DB 00101101b
		DB 00101010b
		DB 00010110b
		DB 00101001b
		DB 01010110b
		DB 00001001b
		DB 00010111b
		DB 00011111b
		
		DB 11000000b
		DB 11110000b
		DB 10100010b
		DB 10110010b
		DB 01100011b
		DB 11100011b
		DB 00000011b
		DB 11011011b
		DB 11101011b
		DB 11100011b
		DB 01000011b
		DB 10100011b
		DB 00000010b
		DB 00000010b
		DB 00000000b
		DB 11000000b		
		
teststr: db "ac"
		 db 0

FIELD0:    ;01234567890123456789012345679012
		DB "a                              a"
		DB "aa                            aa"
		DB "aa                            aa"
		DB "aa                            aa"
		DB "aa   aaaaaaaaaaa              aa"
		DB "aa                            aa"		
		DB "aa                            aa"
		DB "aa                            aa"
		DB "aaaaaaaaaaa  aaa              aa"
		DB "aaaaaaaaaaa  aaa              aa"
		DB "aaaaaaaaaaa    a              aa"
		DB "aaaaaaaaaaa    a              aa"
		DB "aaaaaaaaaaaaa  a              aa"
		DB "aaaaaaaaaaaaa  a              aa"
		DB "aaaaaaaaaaa    a              aa"
		DB "aaaaaaaaaaa    a              aa"
		DB "aa             aa a  aa  aa  aaa"
		DB "aa             a              aa"
		DB "aa  aaaaaaaaaaaa              aa"
		DB "aa                            aa"
		DB "aa                            aa"
		DB "aa  aa        a               aa"
		DB "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"		
		DB 0		
		
DS $6000-$

org	$c800
 ram:
 .ply_y:		rb 1 ; x-pos
 .ply_x:		rb 1 ; y-pos
 .ply_pattern:	rb 1 ; player sprite pattern
 .ply_color:	rb 1 ; player color
 .ply_ws:		rb 1 ; Walk Speed
 .ply_direct:	rb 1 ; direction
 .ply_jstatus:	rb 1 ; Jump Stats (0=none 1=up 2=down)
 .ply_jheight:	rb 1 ; Jump heigth 
 .ply_jspeed:	rb 1 ; Jump Speed
 .ply_jmax:		rb 1 ; max jump height
 .grid_y:		rb 1 ; y-grid pos
 .grid_x:		rb 1 ; x-grid pos
 .Grid_ScanY:	rb 1 ; x-scan 
 .Grid_ScanX:	rb 1 ; y-scan 
 .ply_jump:		rb 1 ; jump 1=yes 0=0
 .ply_stick:	rb 1 ; stick control
 .grid_chr:		rb 1 ; grid CHR code
 .ply_floor1:	rb 1 ;
 .ply_floor2:	rb 1 ;
 .ply_fall:		rb 1 ;
 

Van Pat

Expert (71)

afbeelding van Pat

26-11-2011, 22:56


I would like to energize that long sensing feeling to learn to decently code the msx. And thus, this post.

Whooooww, what's this? Is this serious!?

You didn't tell me anything on this nostalgic feeling of you. Why the f*** do I need to find this out via the MRC?

When I first saw this BlueCrystal nick it triggered me immedialtely, that's the name S. used, is it him?, it is, whow fantastic (uh).

Any time for this revived hobby? Is your kitchen ready? I just finished painting the garage today :-)

Speak to you at Sinterklaas @ Maxet city.

Van BlueCrystal

Expert (101)

afbeelding van BlueCrystal

29-11-2011, 20:36

Hey Pat,

Only been browsing things and looking at snippets of code that float the internet. I think that I grasp the basic concept, but doing it yourself is a whole different world Smile I got some ideas I would like to try out.
The kitchen is close to completion, the plastering just needs more drying. You can continue your paint hobby at my place, if you like Cool

@d-Fader, hey how are you doing? Cool I live in Stein (lb) nowadays. Married, children, the whole package. How is the looong awaited sequel to F1 spirit coming along?

Van phsoft

Supporter (9)

afbeelding van phsoft

09-12-2011, 12:27

Patai Gergely
Z80 Assembly - Index
sgate.emt.bme.hu/patai/publications/z80guide/index.html

Pagina 2/3
1 | | 3