Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
CPColin
Sep 9, 2003

Big ol' smile.
My plan, if my emulation code gets fast enough that this even makes sense to work on, is to check after each tick of the emulator to see if it's time for an interrupt, instead of using a timer. This looks like the way the author of the tutorial did it, too. Good thing, too, because his code doesn't clear the "enable flags" until it's done some work, so would be subject to a race condition.

Adbot
ADBOT LOVES YOU

CRIP EATIN BREAD
Jun 24, 2002

Hey stop worrying bout my acting bitch, and worry about your WACK ass music. In the mean time... Eat a hot bowl of Dicks! Ice T



Soiled Meat
the number of cycles that each instruction takes to execute is documented, so just keep track of cycles. interrupts can't interrupt (heh) an executing instruction so you dont have to worry about it there

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
i just really don't want to go back and add the number of cycles to all of my instructions.

Sapozhnik
Jan 2, 2005

Nap Ghost

CRIP EATIN BREAD posted:

this thread made me look into that emulator101.com page and now im designing UIs for a debugger in ANSI C.

thx, thread

Why not implement a gdb remote debug interface

CPColin
Sep 9, 2003

Big ol' smile.

MALE SHOEGAZE posted:

i just really don't want to go back and add the number of cycles to all of my instructions.

I didn't either, so I made sure to put it in right from the start! (I'm way overengineering this, by the way, but mostly as practice for using TDD. And making Eclipse melt my laptop.)

CRIP EATIN BREAD
Jun 24, 2002

Hey stop worrying bout my acting bitch, and worry about your WACK ass music. In the mean time... Eat a hot bowl of Dicks! Ice T



Soiled Meat

Sapozhnik posted:

Why not implement a gdb remote debug interface

because i get an excuse to write a GUI, something i havent done in ages.

CPColin posted:

I didn't either, so I made sure to put it in right from the start! (I'm way overengineering this, by the way, but mostly as practice for using TDD. And making Eclipse melt my laptop.)

mine is a hot mess of preprocessor token pasting and xmacros

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

JawnV6 posted:

if you get an interrupt and have a long-running instruction pending retirement, do you blow it out intending to re-execute or delay the interrupt until all pending instruction boundaries retire?

what does the reference manual say the real CPU does

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

Sapozhnik posted:

Why not implement a gdb remote debug interface

this is the pro tier solution, then you can even do things like use LLDB’s full-screen terminal UI

JawnV6
Jul 4, 2004

So hot ...

eschaton posted:

what does the reference manual say the real CPU does
who cares, it's packed full of lies

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

CRIP EATIN BREAD posted:

because i get an excuse to write a GUI, something i havent done in ages.


mine is a hot mess of preprocessor token pasting and xmacros

write a GUI around the gdb remote protocol :)

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

CPColin posted:

I didn't either, so I made sure to put it in right from the start! (I'm way overengineering this, by the way, but mostly as practice for using TDD. And making Eclipse melt my laptop.)

see i over engineer everything, so i was like "hmm, i wonder if i should add the number of cycles to the instruction? nah, let's not over engineer this".

brap
Aug 23, 2004

Grimey Drawer
yeah, just go back and add the number of cycles needed for an instruction to each instruction.

building yet-another-z80-emulator or something like that is just grinding in significant part.

necrotic
Aug 2, 2005
I owe my brother big time for this!
dont you need the cycle count if you want an accurate clock?

CPColin
Sep 9, 2003

Big ol' smile.
Space Invaders, the game being emulated in the tutorial, appears to drive its main loop via interrupts, so executing too fast might not actually matter, in this case.

CRIP EATIN BREAD
Jun 24, 2002

Hey stop worrying bout my acting bitch, and worry about your WACK ass music. In the mean time... Eat a hot bowl of Dicks! Ice T



Soiled Meat
i get a kick out of the fact that the 8080 has no shift operations so for space invaders they used special hardware that you used the memory mapped I/O ports to do shifts

JawnV6
Jul 4, 2004

So hot ...
the msp430 doesn't have variable-length shift ops, so the compiler jams in a shift sled and branches to the correct offset

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?
yet again m68k demonstrates its architectural superiority

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

eschaton posted:

yet again m68k demonstrates its architectural superiority

Eschaton, how are things at home?

MononcQc
May 29, 2007

question for low level devs: do you ever have to struggle picking the size of integers you'll use? Do you go like "hm will I ever need to multiply these numbers, better go for a bigger unit" or something or just go "gently caress it, we'll readjust if we need to later, let's just care about overflow behavior".

I realized that I have not frequently needed to make these decisions at a conscious level and I have no good heuristic.

Hunter2 Thompson
Feb 3, 2005

Ramrod XTreme
as a low-level developer who often is wrong:

* uint8_t or int8_t for bytes, typically from a hardware peripheral like UART or I2C, w/e
* size_t or ssize_t for array indices
* uint16_t or int16_t for things that are 16 bit data off of hardware, like PCM audio samples for example. No real point using these for the result of operations because it'll probably* be faster to use 32 bit or 64 bit on modern hardware anyway.
* uint32_t or int32_t for 32-bit things from hardware, and most int operation results where overflow would not be expected
* uint64_t or int64_t for 64-bit things from hardware (a timestamp in microseconds, for example), or if I know I'll need the width to store the result of an operation

* I say probably because I'm not sure. Also the actual memory layout might not even be 16-bit words, it could be stored as 16-bit data in a 32 bit container, I think (but am not sure). However, the compiler will ensure array lookups, etc. get it right.

e: according to this (http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stdint.h.html) the so-called exact-width integer types, such as int32_t, are to have no padding bits, so i'm taking that to mean they are actually the exact width they say they are for all purposes. i think i got the width conflated with memory address alignment in my above wrong statement

Hunter2 Thompson fucked around with this message at 04:17 on Aug 21, 2018

JawnV6
Jul 4, 2004

So hot ...

MononcQc posted:

question for low level devs: do you ever have to struggle picking the size of integers you'll use? Do you go like "hm will I ever need to multiply these numbers, better go for a bigger unit" or something or just go "gently caress it, we'll readjust if we need to later, let's just care about overflow behavior".

I realized that I have not frequently needed to make these decisions at a conscious level and I have no good heuristic.
i wouldn't call it a 'struggle,' but yes i have to knowingly pick the width of every scalar i ever use. most of the time it's obvious

table-stakes interview questions often include a timer that'll overflow 16 bits within hours/minutes, when i've been using a lot of arduino knowing that 2^32 milliseconds rolls over in 53 days comes up

on seriously constrained platforms like the MSP (note that most "low level" folks consider themselves far above machines this anemic) it helps to keep things under the machine size. you can declare a uint64_t and it'll happily break out incrementing it into a SW routine and trash your perf. keeping things native is necessary to be performant

sizes and memory layout come up more when writing structs than individual variables

meatpotato posted:

* size_t or ssize_t for array indices
this is the big exception to fixed-sizes everywhere for everything

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

meatpotato posted:

* uint16_t or int16_t for things that are 16 bit data off of hardware, like PCM audio samples for example. No real point using these for the result of operations because it'll probably* be faster to use 32 bit or 64 bit on modern hardware anyway.

doesn't c have stuff like uint_fast16_t for this reason?

Hunter2 Thompson
Feb 3, 2005

Ramrod XTreme

Jabor posted:

doesn't c have stuff like uint_fast16_t for this reason?

Correct, it does. You can use those but it's a lot of typing. iirc most platforms i've used just alias the uint_fastx_t types to uintx_t (same goes for int_fastx_t and intx_t).

e: might be getting confused with the (u)int_leastx_t types, or maybe they both do it? idk, i'm lazy

Hunter2 Thompson
Feb 3, 2005

Ramrod XTreme
here's some lines from my stdint.h on my piss-poor excuse of computer

/usr/include/stdint.h posted:

28 /* 7.18.1.2 Minimum-width integer types */
29 typedef int8_t int_least8_t;
30 typedef int16_t int_least16_t;
31 typedef int32_t int_least32_t;
32 typedef int64_t int_least64_t;
33 typedef uint8_t uint_least8_t;
34 typedef uint16_t uint_least16_t;
35 typedef uint32_t uint_least32_t;
36 typedef uint64_t uint_least64_t;
37
38
39 /* 7.18.1.3 Fastest-width integer types */
40 typedef int8_t int_fast8_t;
41 typedef int16_t int_fast16_t;
42 typedef int32_t int_fast32_t;
43 typedef int64_t int_fast64_t;
44 typedef uint8_t uint_fast8_t;
45 typedef uint16_t uint_fast16_t;
46 typedef uint32_t uint_fast32_t;
47 typedef uint64_t uint_fast64_t;

Hunter2 Thompson
Feb 3, 2005

Ramrod XTreme
my work experience is a little lacking, but i've never seen anybody using the fast and least versions irl

MrMoo
Sep 14, 2000

I've used the fast versions a lot, but the least ones are for saving memory usage but keeping good performance so should be significantly more abundant on embedded platforms and esoteric data stores. I would guess many would just go with the default types though.

MrMoo fucked around with this message at 03:22 on Aug 21, 2018

Luigi Thirty
Apr 30, 2006

Emergency confection port.

I got a Voodoo2 today and got the Glide headers hooked up to VC6

how the hell do I make a window full screen in win9x

since the voodoo just replaces the video card’s output that means whatever window is up is what windows interacts with lol

Hunter2 Thompson
Feb 3, 2005

Ramrod XTreme
ah this article answers some good basic questions about the explicit stdint types

https://matt.sh/howto-c

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

jit bull transpile posted:

Eschaton, how are things at home?

wonderful :)

just recycled a bunch of old audio and video cassettes and weeded our old CDs, and also got some old Macs from my parents’ house (both 68040 and PowerPC!)

redleader
Aug 18, 2005

Engage according to operational parameters

Luigi Thirty posted:

I got a Voodoo2 today

:pwn:

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

brap posted:

yeah, just go back and add the number of cycles needed for an instruction to each instruction.

building yet-another-z80-emulator or something like that is just grinding in significant part.

you're not my dad!

refactoring rust really blows. #1 worst part of the language for me.

gonadic io
Feb 16, 2011

>>=

MALE SHOEGAZE posted:

you're not my dad!

refactoring rust really blows. #1 worst part of the language for me.

But but my stong and stable types

Why is this in your experience? Lifetimes? Lack of editor support? The language itself?

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

gonadic io posted:

But but my stong and stable types

Why is this in your experience? Lifetimes? Lack of editor support? The language itself?

yeah I should clarify. refactoring is safe, and that's what matters most. it's just a massive chore due to:

1. verbosity of the language coupled with:
2. lack of editor support
3. proliferation of lifetimes, generic bounds, etc (but mostly lifetimes).
4. cleaning up what you thought to be the last compile error only to get owned by the next phase of compilation, whether it's the borrow checker or something else

the most important thing i've done to make refactoring less painful is to do small vertical prototypes to make sure i'm not going to hit any borrow/lifetime issues. this is a good thing in general and i'm glad to be doing it, but it's not something i've needed to do in say, scala (which isn't a great comparison but it's the closest I've got).

DONT THREAD ON ME fucked around with this message at 09:00 on Aug 21, 2018

BobHoward
Feb 13, 2012

The only thing white people deserve is a bullet to their empty skull

Luigi Thirty posted:

I got a Voodoo2 today and got the Glide headers hooked up to VC6

if you want to go further i remember seeing full hw docs on at least one of the voodoo card generations published on the internet

might have been the voodoo3 though, and who knows if they're still available

Luigi Thirty
Apr 30, 2006

Emergency confection port.


it was free baby

BobHoward posted:

if you want to go further i remember seeing full hw docs on at least one of the voodoo card generations published on the internet

might have been the voodoo3 though, and who knows if they're still available

yeah they’re pretty much all available if you know where to look

ultimate goal: spin a cube, on my Voodoo2, in my 386 operating system

I haven’t spun a cube in Windows yet because Glide doesn’t include things like “matrix transformations” that you get with modern systems but I did get some homemade affine rotation and perspective going, which lets me rotate polygons

https://twitter.com/LuigiThirty/status/1031810992534171648

Luigi Thirty fucked around with this message at 09:42 on Aug 21, 2018

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
well, that's not right:


but hey it uh, it's doing something with the display buffer, and that's a big win.

CPColin
Sep 9, 2003

Big ol' smile.
Progress!

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
it took me two hours of debugging to find this:

code:
    pub fn vram(&self) -> [u8; display::FB_SIZE] {
        let mut rng = rand::thread_rng();
        let mut v = [0; display::FB_SIZE];

        for i in &mut v.iter_mut() {
            *i = rng.gen()
        }
	// self.0 is the raw memory buffer.
        //v.copy_from_slice(&self.0[0x2400..(0x3fff + 1)]);
        v
    }
i was generating random data because i wanted to draw something that wasn't static. completely forgot about it.

things look much closer now:

CRIP EATIN BREAD
Jun 24, 2002

Hey stop worrying bout my acting bitch, and worry about your WACK ass music. In the mean time... Eat a hot bowl of Dicks! Ice T



Soiled Meat

MononcQc posted:

question for low level devs: do you ever have to struggle picking the size of integers you'll use? Do you go like "hm will I ever need to multiply these numbers, better go for a bigger unit" or something or just go "gently caress it, we'll readjust if we need to later, let's just care about overflow behavior".

I realized that I have not frequently needed to make these decisions at a conscious level and I have no good heuristic.

short answer: eh

long answer: it depends

Adbot
ADBOT LOVES YOU

AWWNAW
Dec 30, 2008

Luigi Thirty posted:

how the hell do I make a window full screen in win9x

if you haven’t already figured it out I’m pretty sure it’s just a send message call with the window handle and some constant telling it to get big. at least that’s what I recall from like 20 years ago

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply