You are not logged in.
Lost Password?

All Posts (Guy Perfect)




#411
Re: How to print umlauts?
Posted on: 2012/12/24 21:15
VUE(xpert)
Joined 2012/12/4
418 Posts
CoderLong Time User (7 Years)
All ASCII characters fit in 7 bits. The international characters (including those with umlauts) in CP-850 as shown in the image are in the 128-255 range; the highest bit is set.

My guess is that something in the compiler is reading characters as bytes, sign extending them when that high bit is set, and is munging up your result accordingly.

It's hard to diagnose at a glance, but you might see some success if you use unsigned char variables instead of char variables.
Top

Topic | Forum


#412
Re: Help with Hello World
Posted on: 2012/12/24 20:31
VUE(xpert)
Joined 2012/12/4
418 Posts
CoderLong Time User (7 Years)
Quote:
Also, the really awesome thing to use is Mednafen and its debugger. Mednafen is one of the emulators out there. It's debugger will show you all the registers (even VIP) and let you root around in the loaded memory space.

Duly noted, and thanks for the tip. (-:

One of the things I want to do is make a programmer/hacking focused emulator of my own. It's not because there isn't one; I just want to make an emulator and Virtual Boy sounded like a good project. I originally considered NES, and that one's been emulated out the wazoo.

Anyhoo, the point is that when it comes to spiffy Virtual Boy emulation, I hope to bring something to the table!
__________

In other news, I got my first ROM up and running! It won't work on a real Virtual Boy, however, because the VIP column table isn't initialized. But with that one exception, it works like a charm.

My first (and second) attempt was to produce the image I posted in the original post, but it didn't work. Why didn't it work? Who the crap knows; there was a fair amount of code and I had no idea which part of it was wrong. So instead I pulled back a step and consulted Occam, who recommended I do the simplest thing that could possibly work.

So rather than three squares, which is more involved than one might think, I just set out for the simplest output possible: change the color of the screen. And that, much to my delight, worked like a charm. The program does the following:

* Run a dummy loop for 0xFFFF iterations to allow the system pseudo-RAM to warm up. This is specified in the dev manual, and the exact method was taken from Wario Land.
* Clear the status register and disable interrupts. This was also taken from Wario Land.
* Configure World 31 as the control world; no worlds will be drawn to the framebuffers. Come to think of it, I think I was trying to use World 0 in my other program. Whoops!
* Set BRTC to 127 and REST to 0. This controls brightness values.
* Set BKCOL to 3, meaning to use the brightness timing specified by BRTC.
* Set all flags in DPCTRL. This includes the enable flag and display reset signal. The display isn't active with this off.
* Set the XPEN flag in XPCTRL. This enables drawing by the VIP, which is required for the clear color to change.
* Idle forever in a loop. Just call HALT over and over.

The ROM itself is attached to this post. Its code is as follows:


Delay to allow pseudo-RAM to warm up
07000000  20 B0 FF FF  ORI     FFFFh
r0r1
07000004  3F 44        ADD     
-1hr1
07000006  FE 95        BNE     07000004

Clear status and disable interrupts
07000008  05 70        LDSR    r0
PSW
0700000A  00 78        SEI

Set World 31 as the control world
0700000C  20 A0 40 00  MOVEA   0040h
r0r1 END True
07000010  40 A0 BE 3D  MOVEA   3DBEh
r0r2 r2 0x0003DBE0;
07000014  44 50        SHL     4r2
07000016  22 D4 00 00  ST
.H    r10h[r2]

Set BRTC to 127 and REST to 0
0700001A  20 A0 7F 00  MOVEA   007Fh
r0r1
0700001E  40 BC 06 00  MOVHI   0006h
r0r2
07000022  22 D4 28 F8  ST
.H    r1F828h[r2] ; BRTC
07000026  02 D4 2A F8  ST
.H    r0F82Ah[r2] ; REST

Set BKCOL to 3
0700002A  23 40        MOV     3h
r1
0700002C  22 D4 70 F8  ST
.H    r1F870[r2]  ; BKCOL

Set DPCTRL to 0x0703LOCKSYNCEREDISPDPRST
07000030  20 A0 03 07  MOVEA   0703h
r0r1
07000034  22 D4 22 F8  ST
.H    r1F822[r2]  ; DPCTRL

Set XPCTRL to 0x0002XPEN
07000038  22 40        MOV     2h
r1
0700003A  22 D4 42 F8  ST
.H    r1F842h[r2] ; XPCTRL

Idle forever
0700003E  00 68        HALT
07000040  FE 8B        BR      0700003E

The reset handler is fairly uneventful:


FFFFFFF0  20 BC 00 07  MOVHI   0700h
r0r1 main() code is at 0x07000000
FFFFFFF4  01 18        JMP     r1

Attach file:


vb third.vb Size: 1.00 KB; Hits: 146
Top

Topic | Forum


#413
Re: Help with Hello World
Posted on: 2012/12/24 4:35
VUE(xpert)
Joined 2012/12/4
418 Posts
CoderLong Time User (7 Years)
Okay, I've picked through the writes to the VIP control registers. Tomorrow I'll look into trying these out in an emulator.


VIP_REGS
[REST] = 0;

REST is the duration of LED emissions while all three brightness values are disabled. In this case, 0 since you can't see anything.



VIP_REGS
[XPCTRL] = VIP_REGS[XPSTTS] | 2;

Sets XPCTRL.XPEN, which enables VIP drawing. This one's kinda important.



VIP_REGS
[DPCTRL] = VIP_REGS[DPSTTS] | 0x0302;

Sets:
* DPCTRL.LOCK to 1, preventing the VIP from reading the column table every frame
* DPCTRL.SYNCE to 1, indicating that the servo controller should send left and right sync signals to the VIP
* DPCTRL.DISP to 1, enabling the display subsystem. That's another important one.



VIP_REGS
[FRMCYC] = 0;

Specifies the VIP should display 1 image per game frame.



VIP_REGS
[INTCLR] = VIP_REGS[INTPND];

Clears all pending VIP interrupt condition flags.



while (!(VIP_REGS[DPSTTS] & 0x3C));  //required?

Waits until the changes to DPCTRL take effect, and neither the left nor right displays are being shown.
Top

Topic | Forum


#414
Re: Help with Hello World
Posted on: 2012/12/23 22:17
VUE(xpert)
Joined 2012/12/4
418 Posts
CoderLong Time User (7 Years)
Dear lord, it's full of stars. And just like that, my plans take a sharp turn to the left. (-:
Top

Topic | Forum


#415
Re: Help with Hello World
Posted on: 2012/12/23 22:08
VUE(xpert)
Joined 2012/12/4
418 Posts
CoderLong Time User (7 Years)
Quote:
We already have Nintendo's Virtual Boy Development Manual


Do we now? All I've been able to hunt down is David Tucker's doc. Do you have a link to the official manual?
Top

Topic | Forum


#416
Re: Help with Hello World
Posted on: 2012/12/23 21:44
VUE(xpert)
Joined 2012/12/4
418 Posts
CoderLong Time User (7 Years)
I am indeed using assembly; manually and with a hex editor no less. I'm in the process of documenting the system internals, since existing information on the Virtual Boy is only some 75% of what the silly thing actually does. To that end, I've prepared a system and will be getting a FlashBoy in before long to fill in the rest of the holes in our development docs.

Having said all that, I'm no newcomer to reverse engineering. As part of my documentation efforts, I figure the best sure-fire way to do it right is to start at the very bottom and work up, hence why I'm hand-coding a ROM file for basic output. By the time I'm done, we'll have a document at our disposal that looks something like this.

Thanks for the tip about the component registers. I'll look into those and see if I can get the displays to provide more useful output. (-:
Top

Topic | Forum


#417
Help with Hello World
Posted on: 2012/12/23 20:48
VUE(xpert)
Joined 2012/12/4
418 Posts
CoderLong Time User (7 Years)
Hey, I'm attempting to get some barebones output prepared so I can do some reverse engineering, but my emulator tests have been less than promising, so I'm hoping someone could point out what I'm forgetting to do/doing wrong.

All I'm trying to do is produce the following image on both screens:

Open in new window


The way I'm attempting to do this is as follows:

* Initialize PSW to 0x00000000 and disable interrupts with SEI
* Initialize BG map, window params, windows and OAM (0x00020000 to 0x0003FFFF) to 0xFF - Method taken from VB Wario Land
* Initialize character (0x00078000 to 0x0007FFFF) to 0x00 - Also taken from VB Wario Land
* Make character 1 (0x00078010 to 0x0007801F) full; set all bytes to 0xFF
* In BG map 0, set cells 0, 2 and 65 to character 1 with palette 0. This means, as halfwords, set each of 0x00020000, 0x00020004 and 0x00020082 to 01 00
* Set all brightness registers (0x0005F824, 0x0005F826 and 0x0005F828), as halfwords, to 2A 00
* Set BG palette 0 (0x0005F860) as halfword to FF 00
* Set clear color (0x0005F870) as halfword to 00 00
* Configure window 0 (0x0003D800 to 0x0003D820) as such:
- * Left=true, right=true, BGs wide=2^0, BGs tall=2^0, base BG=0 -- 0x0003D800 as halfword = 00 C0
- * Window width = 4 characters (64 pixels) -- 0x0002000E as halfword = 04 00
- * Window height = 64 pixels -- 0x00020010 as halfword = 40 00
- * All other fields = 0
* Initialize "column tables" as outlined in David Tucker's document (link). Written as halfwords with only the lower 8 bits significant.
* Re-enable interrupts with CLI
* HALT forever in a loop
* All interrupts except for Reset are simply RETI

As far as I can tell, everything looks good, but when I run it in an emulator I just get a black display. If anyone could point out what the problem is, such as something else I need to enable somewhere, it'd be super appreciated.
Top

Topic | Forum