New around here? Register your SA Forums Account here!

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
tinaun
Jun 9, 2011

                  tell me...
with enough syntax you can make Result based error handling look like exceptions :v:

Adbot
ADBOT LOVES YOU

Good Sphere
Jun 16, 2018

what’re people’s experience here learning Metal? i made a camera effects ios app using CIFilters, but it drains the crap out of the battery. it’s being beta tested and i’m trying to do something that will optimize it as quick as i can. eventually i’ll add Metal but realistically it will be after release. apparently i can still use the same CIFilters and have the drawing and view be Metal

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?

Slurps Mad Rips posted:

c tp s: i've finally snapped. i've forked gnu m4 and i'm rewriting it in C++17.

I know this is supposed to be a safe space and all but


wha the Christ

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?

MononcQc posted:

Returning errors as value is good, but you have to have a good uniform way to unambiguously be able to get contextual information from the origin of the error as a more remote observer.

yet another place where Lisp gets it right, with the condition system and restarts

Luigi Thirty
Apr 30, 2006

Emergency confection port.

I was going to make a post about my toy OS’ memory allocator but as usual I realized the solution while I was writing it out

so instead I present my glide .obj loader drawing a spinning spaceship

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

unfortunately I don’t have any way to directly record the voodoo output so I hope you like “camera pointed at screen”

Luigi Thirty
Apr 30, 2006

Emergency confection port.

Good Sphere posted:

what’re people’s experience here learning Metal? i made a camera effects ios app using CIFilters, but it drains the crap out of the battery. it’s being beta tested and i’m trying to do something that will optimize it as quick as i can. eventually i’ll add Metal but realistically it will be after release. apparently i can still use the same CIFilters and have the drawing and view be Metal

metal is rly cool but I found that the docs are a mix of out of date, in objective-c, and confusing af.

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

tinaun posted:

with enough syntax you can make Result based error handling look like exceptions :v:

problem: writing "Ok(foo)" in a function that might fail is cumbersome, it would be much better to write "foo" and make you look at the signature to figure out that it's a Result

solution: replace "Result<T, E>" with "T throws E" to trigger the above behaviour, also add a macro "throw!(foo)" which is obviously much shorter than "Err(foo)?"

:ok:

Tankakern
Jul 25, 2007

Good Sphere posted:

what’re people’s experience here learning Metal? i made a camera effects ios app using CIFilters, but it drains the crap out of the battery. it’s being beta tested and i’m trying to do something that will optimize it as quick as i can. eventually i’ll add Metal but realistically it will be after release. apparently i can still use the same CIFilters and have the drawing and view be Metal

stop doing what you're doing and make it in vulkan with moltenvk instead

Tankakern
Jul 25, 2007

there's never a reason to choose metal

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 9 years!)

Tankakern posted:

stop doing what you're doing and make it in vulkan with moltenvk instead

this but the whole app and use react native, op

suffix
Jul 27, 2013

Wheeee!

gonadic io posted:

poo poo i've just had a great idea. make my own version of try! that automatically annotates the error with standard stack-tracey stuff. failure has a bunch of macros but i didn't see one that did this. too bad that the ? syntax is special and you can't override it with a trait or whatever like you can with + etc

error-chain does this when you do chain_err, i'm pretty sure
from what i can tell error-chain will be deprecated and failure is the new hot stuff but i'm not looking forward to switching, failure looks pretty anemic in comparison

gonadic io
Feb 16, 2011

>>=

suffix posted:

error-chain does this when you do chain_err, i'm pretty sure
from what i can tell error-chain will be deprecated and failure is the new hot stuff but i'm not looking forward to switching, failure looks pretty anemic in comparison

failure does this too with context or something, but the point is you still have to do

code:
foo_result.context(format!("{}:{}", line!(), char!()))?
or some bullshit.

still though failure is basically Strictly Better than error chain which is why the latter is deprecated in favour of the former

Hunter2 Thompson
Feb 3, 2005

Ramrod XTreme
just wanna thank symbolic butt for posting about that programming languages coursera class earlier in this thread. i'm learning to weird via sml and liking it a lot

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

meatpotato posted:

just wanna thank symbolic butt for posting about that programming languages coursera class earlier in this thread. i'm learning to weird via sml and liking it a lot

:tipshat:

cinci zoo sniper
Mar 14, 2013




meatpotato posted:

just wanna thank symbolic butt for posting about that programming languages coursera class earlier in this thread. i'm learning to weird via sml and liking it a lot

oh right there were like a few pages of educational links some time ago that i forgot to revisit, was reading them from phone

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?

Luigi Thirty posted:

metal is rly cool but I found that the docs are a mix of out of date, in objective-c, and confusing af.

but you’re an expert now so none of that will slow you down!

implement Glide atop Metal for porting your game

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?

Tankakern posted:

there's never a reason to choose metal

sure there is: you want to get the best possible experience for your users by using native technologies supported by the platform vendor instead of using third party wrapper libraries that exist mostly for ideological reasons

Finster Dexter
Oct 20, 2014

Beyond is Finster's mad vision of Earth transformed.

meatpotato posted:

just wanna thank symbolic butt for posting about that programming languages coursera class earlier in this thread. i'm learning to weird via sml and liking it a lot

cinci zoo sniper posted:

oh right there were like a few pages of educational links some time ago that i forgot to revisit, was reading them from phone

Oh let me just search for those... RIP

Can we put them in the OP? :pray:

Hunter2 Thompson
Feb 3, 2005

Ramrod XTreme

Symbolic Butt posted:

a couple of online courses that made a huge impression on me:

CS212 Design of Computer Programs by Peter Norvig is probably my favorite course ever. it's kind of a unique course on algorithms/data structures but a lot more pragmatic.

he also introduces a lot of design patterns in a sneaky way, if you plan to really get into that it'll definitely help to already have the general intuition that Norvig gives you here.

if that's a heavy course to you maybe give it a pause and try CS101 Intro to Computer Science, it's a way more basic course but it touches on a lot of intermediate topics that you may not be familiar with.


Programming Languages by Dan Grossman is a great intro to PLT. It's about learning 3 languages and their key ideas (SML, Racket and Ruby). it forces you to think about a lot of stuff you never really think about in introductory p-lang courses (typing, mutability, scoping, dispatch etc)

compared to CS212 this is hella formal and academic so it may or may not be your cup of tea. Starting with SML may be a huge shock but is totally worth it. I really like this course better than just learning just one fp language in isolation because it puts other paradigms side by side to give you a better perspective.

Luigi Thirty
Apr 30, 2006

Emergency confection port.

eschaton posted:

but you’re an expert now so none of that will slow you down!

implement Glide atop Metal for porting your game

I need to figure out how per-vertex lighting calculations work first so I can actually light my models

Slurps Mad Rips
Jan 25, 2009

There's No Guarantee

eschaton posted:

I know this is supposed to be a safe space and all but


wha the Christ

i dunno man it’s been fun so far to destroy all the old busted code and get this working on windows :v:

Slurps Mad Rips fucked around with this message at 03:01 on Aug 26, 2018

Luigi Thirty
Apr 30, 2006

Emergency confection port.

speaking of things that are busted, the entire STL in VC6

Slurps Mad Rips
Jan 25, 2009

There's No Guarantee

Luigi Thirty posted:

speaking of things that are busted, the entire STL in VC6

yeah thats dinkumware for you. MS doesn’t contract with them anymore. it’s also why lots of gamedevs wrote their own stdlib stuff for the next decade or so :v:

if you need an STL for that time period I recommend you look into STLPort. there’s deffo a version that supports vc6 somewhere on sourceforge. also maybe grab the last version of boost to support vc6 so you can get decent string/vector implementations

Luigi Thirty
Apr 30, 2006

Emergency confection port.

literally anything would be better than the existing vector, which actually didn’t work until I installed VC6 service pack 6

now getline doesn’t work! I will look at ancient boost

e: ok google says 1.36 is the last one that explicitly supports VC6 and 1.34 is the last one precompiled for it, so that’s 2008ish

Luigi Thirty fucked around with this message at 03:19 on Aug 26, 2018

akadajet
Sep 14, 2003

eschaton posted:

sure there is: you want to get the best possible experience for your users by using native technologies supported by the platform vendor instead of using third party wrapper libraries that exist mostly for ideological reasons

lmao

CPColin
Sep 9, 2003

Big ol' smile.
c emulator101 s: really glad I wrote all these loving tests for each and every opcode, because I'm about to refactor the poo poo out of things so I can support interrupts properly. (An interrupt can inject any one-, two-, or three-byte operation into the CPU's piss stream, not just RST operations, so, in cases where the operation doesn't already change the PC, any automatic incrementing of the PC that would normally happen has to be suppressed. All my emulation code was explicitly incrementing the PC and now has to do it implicitly so interrupt processing can skip it properly.)

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

CPColin posted:

c emulator101 s: really glad I wrote all these loving tests for each and every opcode, because I'm about to refactor the poo poo out of things so I can support interrupts properly. (An interrupt can inject any one-, two-, or three-byte operation into the CPU's piss stream, not just RST operations, so, in cases where the operation doesn't already change the PC, any automatic incrementing of the PC that would normally happen has to be suppressed. All my emulation code was explicitly incrementing the PC and now has to do it implicitly so interrupt processing can skip it properly.)

ah yeah, having my main loop implicitly increment the PC seemed like a code smell, so I designed it so that each instruction is responsible for advancing the PC. this lead to a lot of bugs where I forgot to advance the PC, but I'm glad I did it.

i'm totally stumped on the behavior i'm seeing currently. something is wrong. I'm currently implementing better debugging than I had previously (storing the op history in a ring buffer for inspection on failure, etc). if that doesn't solve the problem, i'll probably take a break from this because it's working to my satisfaction.

there's a guide for writing an OS in rust i might try next.

CPColin
Sep 9, 2003

Big ol' smile.

MALE SHOEGAZE posted:

ah yeah, having my main loop implicitly increment the PC seemed like a code smell, so I designed it so that each instruction is responsible for advancing the PC. this lead to a lot of bugs where I forgot to advance the PC, but I'm glad I did it.

Heh, I'm refactoring in the other direction. Each instruction right now explicitly advances the PC. That's not supposed to happen when processing an interrupt and I don't want to add "if (interrupt)" to each of my instructions, so I'm moving toward handling the PC in one place like this:

if PC was set explicitly, use that
else if processing an interrupt, keep PC the same
else advance PC by the size of the instruction

And since I wrote a test for every instruction that verifies the PC advanced, I can do this refactor safely! Whee!

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
wouldnt it make sense to save the PC before the interrupt and then restore it afterwards? seems like that's a lot easier

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

CRIP EATIN BREAD posted:

wouldnt it make sense to save the PC before the interrupt and then restore it afterwards? seems like that's a lot easier

then you have to not restore it if the interrupt instruction was a jump

but do still restore it if it was a conditional jump that wasn't taken

even if the jump location happens to be the same as advancing the program counter normally

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

CPColin posted:

Heh, I'm refactoring in the other direction. Each instruction right now explicitly advances the PC. That's not supposed to happen when processing an interrupt and I don't want to add "if (interrupt)" to each of my instructions, so I'm moving toward handling the PC in one place like this:

if PC was set explicitly, use that
else if processing an interrupt, keep PC the same
else advance PC by the size of the instruction

And since I wrote a test for every instruction that verifies the PC advanced, I can do this refactor safely! Whee!

ah, i misunderstood. maybe this is the source of my current issues.

CPColin
Sep 9, 2003

Big ol' smile.
I'm also just realizing I have a problem with how I return from interrupts. Normally, when executing a RET operation, you want the PC to end up pointing at the instruction after the CALL that led to the RET, or you'll get stuck in a loop. When you're returning from an interrupt handler, you're returning to an instruction that isn't CALL (or one of the conditional calls), so you'd better keep the PC where it was! So I guess I need to add an "if returning to a CALL, RST, etc., increment PC" check, ugh.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
ah okay. i get what you're talking about now. in the emulator101 we don't implement full interrupts, just RST 1 and RST 2, and it doesn't matter if you increment the PC there since the executed code just returns to the stored PC.

CPColin
Sep 9, 2003

Big ol' smile.
Yeah, I think this is a case where the 8080 data book gave me the wrong impression. For CALL and its variants, it says, "a return address is pushed onto the stack for use by the RETURN instructions." For RST, it says, "The contents of the program counter are pushed onto the stack, providing a return address for later use by a RETURN instruction."

I think it should mention that the return address should be the current PC, when processing an interrupt, and the address of the subsequent instruction, when not processing an interrupt. That's how I'm going to do it, I guess, and I'll see what happens!

But yeah, the only reason this is an issue is because I'm making it harder on myself by supporting RST in normal program flow and supporting interrupts that aren't RST.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
aggh i fixed it, my SHLD instruction was wrong. only found it with manual inspection. not an interesting bug, just a simple mistake.

i think attract mode is working!

e: hmm well it seems the alien spaceships don't take damage in attract mode. that must be wrong?

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

CPColin
Sep 9, 2003

Big ol' smile.
Oof, started to get disheartened by how slow this code is, to the point where I was about to quit, because it would take forever to draw each frame. Wisely got a profiler going and discovered a fun quirk in Ceylon:

code:
// This code:
doSomethingWithAttribute(`Foo.attribute`);

// is like ten times slower than this code:
doSomethingWithAttribute(fooAttribute);

// assuming we cached the value elsewhere:
Attribute fooAttribute = `Foo.attribute;
aaaaaag Ceylon don't dynamically resolve a value that really looks like a constant!

but hooray for profilers

Edit: It used to take five minutes for my emulator to reach the first "one-second delay" loop and now it just took fifteen seconds. And most of that was printing the output from the disassembler.

Night Shade
Jan 13, 2013

Old School

CPColin posted:

c emulator101 s:

pre:
U IS OPERATIONALCPU IS OPERATIONALCPU IS OPERATIONALCPU IS OPERATIONALCPU IS OPERA
now to implement rst and put in an interface for io and interrupts

e: this is your fault, MALE SHOEGAZE, but seriously thanks for the inspiration to do a neat side project

ctps: cpu.fs contains little more than a 950 line tail-recursive function

Night Shade fucked around with this message at 00:57 on Aug 27, 2018

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.
you people and your 8080s. try implementing something fun and esoteric, like a belt machine. if your want real fun, build the whole thing in VHDL after your emulator is working.

i did that for a masters course and still have nightmares

CPColin
Sep 9, 2003

Big ol' smile.
Java image processing is loving esoteric as all hell, but it's nice it has at least some capacity for me to copy my video RAM straight into an image raster :toot:

Only registered members can see post attachments!

Adbot
ADBOT LOVES YOU

CPColin
Sep 9, 2003

Big ol' smile.
(lol except the bytes in the video RAM are packed little-endian and Java is expecting big-endian whoops)

Only registered members can see post attachments!

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