POV-Ray : Newsgroups : povray.advanced-users : Why?... Because!! : Why?... Because!! Server Time
29 Jul 2024 02:29:26 EDT (-0400)
  Why?... Because!!  
From: Andrew Coppin
Date: 12 Mar 2003 16:12:06
Message: <3e6fa2a6@news.povray.org>
The new docs for PV3.5 contain a tutorial which shows you how to write a
raytracer using POV-Ray's SDL... Far out man! A raytracer simulating a
raytracer!!!

I think I may have just gone one better. Man, I bet someone else has already
done this tho |'-[ What have I done? I've only used the SDL to create an
emulator for an 8-bit computer!!! Yup, write an include file to fill a
region of the "memory" with the correct op-codes, then ask POV-Ray to render
an animation. Between each frame POV-Ray will execute one machine code
instruction.

The actual image that gets rendered is a bunch of 8-segment "LCD" displays.
(The individual segments can be switched on and off by writing the correct
bitmap value into certain memory addresses; memory-mapped I/O baby!) Also at
the bottom of the screen is a dump of the CPU state - PC, SP (and the memory
they point to), status flags and general purpose registers.

As such, the "animation" is actually best viewed as a frame-by-frame slide
show. As you can imagine, since all you're seeing is a page of code numbers
that change now and then, it's actually really hard to follow!!! I'm
thinking if I really wanted to I could create a more graphical illustration
of what's going on. (Would probably still tend to me a bit mesmerising and
require lots of concentration to follow it! LOL)

Why did I do this???

Well, for years I've been having these delusions that one day I will write
my own operating system. Of course, I couldn't possibly write an operating
system for an IBM PC - I simply don't have access to the requisite
information. I don't even know Intel assembly! Never mind all the different
protocols and chipsets for I/O... It's simply beyond my abilities. But one
of my other "lifetime ambitions" is to build my own computer - out of
individual logic gates! Of course, I haven't managed to do that yet
either... So now I'm building an emulator! At least now I can get
programming while I wait for the computer to take shape... (Hey, I could
even emulate the logic gates, couldn't I??? Mmmm....)

I actually have a C64 emulator... But I don't like some of the way the 6502
works... So I designed my own microprocessor. And now I can emulate it!
Yay!!!

[Aside] So am I completely nuts? Opinions? [/Aside]

Anyway, will post the sources - if anyone besides me actually gives a sod
that is! They're kinda big (POV-Ray works out what to do with each op-code
using a MASSIVE #switch statment - and the instruction set is about 90
codes!) But hey, there's always WinZIP (if folks have that or equivelent).
It's very uncommented ("hey, *I* know what I'm doing...") and probably still
very buggy ("oops - look at that; I got the address and data the wrong way
round...") but hey ;-)

The biggest "program" I've written so far is about 30 instructions. The
first part adds two numbers together, and the second part (the big bit!) is
a subroutine that takes a number is displays (in hex) on the 8-segment
display. So... in other words, with 30 instructions of code, you get the
same printout every time. *sigh* But hey, if you changed just 2 bytes, you


Knackered.
Andrew.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.