You are not logged in.
Lost Password?

All Posts (cr1901)




#11
Re: A newer GCC compiler.
Posted on: 2016/4/18 12:03
Virtual Freak
Joined 2014/8/31
USA
83 Posts
Long Time User (5 Years)App Coder
Quote:

ElmerPCFX wrote:
void pointers??? They're not declared as function pointers???


They're u32s :P. I just called them void pointers b/c that's really what they represent. https://github.com/cr1901/vbdemo/blob/ ... vers/timedriv.c#L110-L113
Top

Topic | Forum


#12
Re: A newer GCC compiler.
Posted on: 2016/4/18 5:58
Virtual Freak
Joined 2014/8/31
USA
83 Posts
Long Time User (5 Years)App Coder
Quote:

ElmerPCFX wrote:
OTOH ... It's getting really, really hard to compile a working GCC 2.95 anymore because modern linux toolchains barf on some of the early-GCC-specific code that's in there. You pretty much need to find an old GCC 3.x compiler from somewhere.


This is a bit ironic, considering 2.95 can in theory be built with a K&R compiler. I recall there being a "make bootstrap" target in 2.95 that provides an alternate "Stage 1" for compilers that choke on the code?

Also, re: the interrupt handlers, the 4.4 startup code (presumably the 2.95 code as well) provides a few extern vars which map directly to where the CPU jumps on an interrupt. You create your interrupt handler in C, and then convert the handler's addr to a void pointer and assign them to the desired external vector addresses.

[pedantic]Of course, this can't be done in ANSI C, but because POSIX compilers require being able to convert function pointers to void, and since [jest]nobody cares about compatibility with VUCC[/jest], no harm done.[/pedantic]
Top

Topic | Forum


#13
Nod to Planet VB on C.H.I.P. website
Posted on: 2016/4/17 11:35
Virtual Freak
Joined 2014/8/31
USA
83 Posts
Long Time User (5 Years)App Coder
C.H.I.P., depending on who you ask, is the first $9 single board computer. For April Fool's Day this year, they decided to use their Pocket C.H.I.P. as a VR platform.

The article makes a nod to the the hard work of PlanetVB when testing out their headset :D!

Quote:
But a solid case design is only half of PockulusC.H.I.P.ís magic. Mednafen, the multi-console emulation software, takes PockulusC.H.I.P. out of this world. Plus, it has support for our favorite VR platform. Yes, thatís right, Virtual Boy!

Track down some homebrew ROMs, and then launch Mednafen with this monstrous single-line command.


Enjoyable read for me!
http://blog.nextthing.co/pockulusc-h- ... et-in-the-world/#more-418
Top

Topic | Forum


#14
Re: A newer GCC compiler.
Posted on: 2016/4/17 11:29
Virtual Freak
Joined 2014/8/31
USA
83 Posts
Long Time User (5 Years)App Coder
I'm going to be perfectly honest: I've lost track of the number of GCC versions for VB there are lol. Perhaps we should document them somewhere in a sticky thread?

I can think of 4 offhand:
* 2.9.5 that's existed for ages
* blitter's 4.4
* Dasi's 4.7
* Elmer's 4.7

IIRC, the startup code is more or less the same between all but the last one (in fact, I believe blitter's even reuses the 2.9.5 file for this and relocations).

Last year, I started my own port, that didn't get far b/c of real life. I would be interested in trying an LLVM port tho at some point, even if it has already been done. V810 is one of the only CPUs where I could reasonably succeed in such a port.
Top

Topic | Forum


#15
Re: Scanner questions
Posted on: 2015/5/21 2:34
Virtual Freak
Joined 2014/8/31
USA
83 Posts
Long Time User (5 Years)App Coder
https://github.com/cr1901/vbdemo/commi ... 3376794c659a64428798432c3

If I compile the above unoptimized ROM and run it on a real Virtual Boy, I get different behavior compared to Mednafen. On a real VB, only whole lines are not drawn (and curiously, the lines which do not get drawn vary despite me syncing to XPEND). On Mednafen, parts of lines may be drawn before the scanner displays a column before this little program can plot the next point in a line.

I'm not sure how to interpret this, but it suggests to me that VRAM *is* in fact locked during drawing, or that the framebuffer display start is in general happening in between function calls to draw_line (plausible- create_point() spills into memory)

To save trouble compiling using SCons (it does require a bit of setup if you're not used to it), I have provided the unoptimized ROM. The lack of optimizations is deliberate for now- there are more lines drawn than there is time to draw them (works fine on -O2; there are also plenty of optimization opportunities in O0). Also, create_point() isn't exactly lightweight in its current form. When -O2 is enabled, the output looks like this:
Open in new window


I need to take hi-speed video of this. Seriously, do NOT watch on a real Virtual Boy for prolonged periods of time. I'm not responsible for any headaches.

Attach file:


vb vbdemo_pad.vb Size: 2,048.00 KB; Hits: 152
Top

Topic | Forum


#16
Re: Scanner questions
Posted on: 2015/5/20 20:09
Virtual Freak
Joined 2014/8/31
USA
83 Posts
Long Time User (5 Years)App Coder
What's the difference between FRAMESTART and XPEND? I was confusing the two, and in fact if I sync to FRAMESTART (at which point, VIP calculations should occur), virtually nothing gets drawn to the screen. Are the display buffers locked while the VIP is doing calculations?

I set: WA[31].head = WRLD_END;, so the amount of time taken for the VIP to draw should be trivial (the only thing I can think of is that the VIP doesn't acknowledge WRLD_END before my test routine is done plotting to possibly locked display buffers). Even the VB manuals says it's safe to manipulate framebuffers after the VIP is done drawing.
Top

Topic | Forum


#17
Scanner questions
Posted on: 2015/5/16 5:30
Virtual Freak
Joined 2014/8/31
USA
83 Posts
Long Time User (5 Years)App Coder
GuyPerfect, these questions are mainly for you, since you've actually tested a VB on the bench.

I wish to time a gfx routine that I wrote, and I want to synchronize it to not necessarily what the VIP thinks is the start of a new frame, but the time immediately after the LED array turns off and the mirrors start slowing down to reverse direction- i.e. what the scanner/mirrors think is the "start of the time where it's safe to draw".

I'm having trouble actually visualizing the process of one frame, however (there IS a lot going on inside the scanner), but I think if we take it a few questions at a time, I'll be able to understand the process. Let's start with a few I have offhand.

1. If you go to page 3-3-1 of Nintendo's manual, you'll see a nice little graph of what the mirror's oscillation looks like. There are 10 labelled points on this graph.

Drawing occurs between points 4-6 and 8-10. Am I supposed to interpret 4-6 and 8-10 as "the same LED array being powered on twice", or "the left LED array is powered from 4-6" and "the right LED array is powered from 8-10"?

I'm guessing it's the latter, but the graph is misleading. It makes me think that the graph represents only the movement for either the left or right mirror, not a composite. It also doesn't make much sense for the same LED array to trigger twice in one, since the LED array would illuminate columns at unevenly spaced intervals as the mirror made a sweep back to its initial position.

2. On the same token however, the same page states that the mirrors oscillate 180 degrees out of phase. If the graph is a composite of both mirror movements, this seems to imply that the mirrors are NOT out of phase- just that the LEDs are triggered while one mirror is moving in one direction, and while the other mirror moves in the opposite direction.

This would be so much easier with a visual demonstration! So here's some bad ASCII art. Which best describes the physical movement of the VB mirrors under normal conditions?


/ \ => | | => \ / => | | => / \


OR


\ \ => | | => / / => | | => \ \



3. Looking at the same graph, at what points 1-10 are SCANRDY and L_SYNC and R_SYNC asserted if it is known (page 3-6-1)?

This should be enough to get me started!
Top

Topic | Forum


#18
Re: Fixing GCCVB 4.x Issues
Posted on: 2015/5/16 1:53
Virtual Freak
Joined 2014/8/31
USA
83 Posts
Long Time User (5 Years)App Coder
FWIW, in my test code, O3 works correctly in Mednafen. So whatever that ld.w is doing doesn't seem to be breaking anything. Won't be able to test real hardware until later.
Top

Topic | Forum


#19
Re: Fixing GCCVB 4.x Issues
Posted on: 2015/5/15 10:46
Virtual Freak
Joined 2014/8/31
USA
83 Posts
Long Time User (5 Years)App Coder
Okay, I'm officially confused now as to what GCC 4.2 is thinking here...

Consider the following code- loadfail.c:

#include "libgccvb/libgccvb.h"

void test_load()
{
    
WA[31].head WRLD_END;
}


-O0 produces the following:

.file    "loadfail.c"
    
.section .text
    
.align 2
    
.global _test_load
    
.type    _test_load, @function
_test_load:
    
add -4,sp
    st
.w r29,0[sp]
    
mov sp,r29
    movhi hi
(_WA),r0,r10
    movea lo
(_WA),r10,r10
    ld
.w 0[r10],r10
    addi 992
,r10,r10
    movea lo
(64),r0,r11
    st
.h r11,0[r10]
    
mov r29,sp
    ld
.w 0[sp],r29
    add 4
,sp
    jmp 
[r31]
    .
size    _test_load, .-_test_load
    
.ident    "GCC: (GNU) 4.4.2"


Makes sense to me. -O1 to -O3 however, produce something rather weird to me.

.file    "loadfail.c"
    
.section .text
    
.align 2
    
.global _test_load
    
.type    _test_load, @function
_test_load:
    
movhi hi(_WA),r0,r10
    ld
.w lo(_WA)[r10],r10
    movea lo
(64),r0,r11
    st
.h r11,992[r10]
    
jmp [r31]
    .
size    _test_load, .-_test_load
    
.ident    "GCC: (GNU) 4.4.2"

Maybe it's because it's 4:30AM, but I can see how a load from a control register address (since _WA=0x0003D800, r10 holds 0x00030000 by the time ld.w lo(_WA) rolls around...) is going to help to get the right address of the World Attributes base register into r10 by any stretch of the imagination.

This isn't a fluke either. By -O2, all address loads in all files seem to be replaced with this optimized form. I can't really test right now, but doing a load from memory to generate a base address (instead of using movea) seems wrong. Can anyone possibly explain why this works?

EDIT: Wait a second, it's in the unoptimized version too!

ld
.w 0[r10],r10
addi 992
,r10,r10

WHY is there a load to r10?! There's absolutely no guarantee that _WA will be 0, and the addi might generate a bad address!
Top

Topic | Forum


#20
Re: Fixing GCCVB 4.x Issues
Posted on: 2015/5/14 17:56
Virtual Freak
Joined 2014/8/31
USA
83 Posts
Long Time User (5 Years)App Coder
Yes, I'm glad I could fix a bug by recognizing that it is, in fact, not a bug :P. I do understand why it could be seen as a bug. I haven't taken a look at the .md as to why this particular code sequence is generated.

Since a repeated JMP misses its destination by a power of two, I can't help but wonder if that is related to the jump range of -/+32MB...
Top

Topic | Forum