• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:

  • You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
  • You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
  • If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.

Previously on "Further qualifications and the BCS"

Collapse

  • Bob Dalek
    replied
    Originally posted by NickFitz View Post
    Excellent, apart from the final sentence! It is indeed correct that it should have just been adding the immediate value 100, rather than looping 100 times adding the immediate value 1... but the add-with-carry (hence the mnemonic ADC) of value zero to the high-order byte is correct, to accommodate the case where the low-order byte value overflows from below-or-equal-to 0xFF to above-or-equal-to 0x00 (I'm speaking of the general case here, not the "add 1" situation we see in this example) and the carry from the low-order byte needs to be added to the high-order byte.



    PDP8/e (YMMV, especially if you've always used microprocessor-based machines)



    Excellent again! Except that he does need to do the ADC of zero to the high-order byte, as explained above.

    You are correct to assume that the score was held as a 16 bit (two byte) value, and that this would mean that scores above 65,535 would roll over to zero + (score - 65,536). However - a constraint that I didn't mention - this was not a problem in this particular game, as (like most games of the era) the score was internally held as a two byte value, but the display of the score had a couple of extra zeroes, that remained constant, on the end. Thus, when adding 100 to the score, it appeared to the player as if their score had increased by 10,000 - smoke and mirrors, but psychologically powerful The gameplay was such that no (internal) score as high as 65,536 could ever be achieved, so this was not an issue.

    BTW, some early arcade and home computer games were subject to spectacular and/or interesting bugs when internal values overflowed the 255 or 65,535 boundaries because the programmers had underestimated the lengths people would go to in playing these things, but that wasn't the case with this one - it wasn't primarily a point-scoring game, the points in question were only relevant to a round (or level) of the game, and could never reach 65,536.

    Given this, we can take the facts that:

    a) The 6502 is actually capable of adding 100 to a byte;
    b) Therefore, we don't need a loop;
    c) Nonetheless, the state of the Carry flag is indeterminate when this subroutine is called;

    to achieve:

    Code:
    .add100points
       CLC
       LDA scorelo
       ADC #100
       STA scorelo
       LDA scorehi
       ADC #0
       STA scorehi
       RTS
    FTW

    FWIW, the reason we determined very soon that something dodgy was going on with his code was that there was a terrible flicker of the display (it was a pseudo-FPP-driving game) whenever one got the 100-point (== 10, 000 point) bonus - that lovely little loop of his used up nearly half a frame on the C64's 1MHz processor, called from a code block within which interrupts were disabled, which of course played merry hell with the timings

    Top marks to you both, say I
    You have posted a 1986 GCSE Computing paper and I claim my free copy of "Revenge" by The Eurythmics.

    Leave a comment:


  • NickFitz
    replied
    Originally posted by aussielong View Post
    I'll bite. Doesn't it do a loop of 100 "+1"s just to add 100 to scorelo? Why not just add 100, instead of adding 1, 100 times? Aswell as adding 0 to a number, 100 times!
    Excellent, apart from the final sentence! It is indeed correct that it should have just been adding the immediate value 100, rather than looping 100 times adding the immediate value 1... but the add-with-carry (hence the mnemonic ADC) of value zero to the high-order byte is correct, to accommodate the case where the low-order byte value overflows from below-or-equal-to 0xFF to above-or-equal-to 0x00 (I'm speaking of the general case here, not the "add 1" situation we see in this example) and the carry from the low-order byte needs to be added to the high-order byte.

    Originally posted by bogeyman View Post
    Ahhh
    6502 assembler
    Beans on toast for tea
    Jumpers for goalposts
    PDP8/e (YMMV, especially if you've always used microprocessor-based machines)

    Originally posted by bogeyman View Post
    For the curious, this hotshot game dev adds 1 to 'scorelo' one hundred times, in a loop. Just to be fair, he adds zero to 'scorehi' while he's at it. Presumably he doesn't know that ADC (add with carry) will accept numbers greater than one, or that 'scorehi' won't feel neglected if you don't also give it some love by adding zero to it 100 times. Note how he carefully clears the carry flag (CLC) for every iteration of the loop.

    Presumably the task was to allow for scores >= 255 with the 'lo' and 'hi' bytes representing low and high order bytes of a 16-bit integer. As it stands you'd see your score drop back alarmingly just when you thought you were getting somewhere - like on the Weakest Link when they don't 'bank'.
    Excellent again! Except that he does need to do the ADC of zero to the high-order byte, as explained above.

    You are correct to assume that the score was held as a 16 bit (two byte) value, and that this would mean that scores above 65,535 would roll over to zero + (score - 65,536). However - a constraint that I didn't mention - this was not a problem in this particular game, as (like most games of the era) the score was internally held as a two byte value, but the display of the score had a couple of extra zeroes, that remained constant, on the end. Thus, when adding 100 to the score, it appeared to the player as if their score had increased by 10,000 - smoke and mirrors, but psychologically powerful The gameplay was such that no (internal) score as high as 65,536 could ever be achieved, so this was not an issue.

    BTW, some early arcade and home computer games were subject to spectacular and/or interesting bugs when internal values overflowed the 255 or 65,535 boundaries because the programmers had underestimated the lengths people would go to in playing these things, but that wasn't the case with this one - it wasn't primarily a point-scoring game, the points in question were only relevant to a round (or level) of the game, and could never reach 65,536.

    Given this, we can take the facts that:

    a) The 6502 is actually capable of adding 100 to a byte;
    b) Therefore, we don't need a loop;
    c) Nonetheless, the state of the Carry flag is indeterminate when this subroutine is called;

    to achieve:

    Code:
    .add100points
       CLC
       LDA scorelo
       ADC #100
       STA scorelo
       LDA scorehi
       ADC #0
       STA scorehi
       RTS
    FTW

    FWIW, the reason we determined very soon that something dodgy was going on with his code was that there was a terrible flicker of the display (it was a pseudo-FPP-driving game) whenever one got the 100-point (== 10, 000 point) bonus - that lovely little loop of his used up nearly half a frame on the C64's 1MHz processor, called from a code block within which interrupts were disabled, which of course played merry hell with the timings

    Top marks to you both, say I

    Leave a comment:


  • bogeyman
    replied
    Originally posted by aussielong View Post
    Eh? What's up? You can use that word on Countdown, so why not here?

    ZX48K? If that is the correct name? The first Spectrum that was popular. Rubber keys. Joysticks made from two lollipop sticks and a rubber dart stuck to the keys.
    yer not wrong: http://uk.youtube.com/watch?v=7gBXPUSXGWs

    Leave a comment:


  • aussielong
    replied
    Originally posted by bogeyman View Post
    Ferret? FERRRRRRETTTTTTT!

    We have a transgressor!

    Pardon my ignorance but what on earth is a ZX48?

    Is that some very early, post WWII home computer that Clive Sinclair devised as a lad using left over valves and relays from Bletchley Park?
    Eh? What's up? You can use that word on Countdown, so why not here?

    ZX48K? If that is the correct name? The first Spectrum that was popular. Rubber keys. Joysticks made from two lollipop sticks and a rubber dart stuck to the keys.

    Leave a comment:


  • bogeyman
    replied
    Originally posted by aussielong View Post
    I started out writing games on the ZX48 in the mid-80s in BASIC as a hobby. I used to dabble in Z80. I remember being amazed that you could draw in the Border on the Spectrum. Take up the whole screen instead of just the bit inside the border. Last game i played was in about 1990. Those two quid CodeMasters games. Some of them were great! Tape to Tape at my mates house. Get 10 on a C60 cassette! Yes, I did a lot of w*****g back then.
    Ferret? FERRRRRRETTTTTTT!

    We have a transgressor!

    Pardon my ignorance but what on earth is a ZX48?

    Is that some very early, post WWII home computer that Clive Sinclair devised as a lad using left over valves and relays from Bletchley Park?

    Leave a comment:


  • aussielong
    replied
    Originally posted by bogeyman View Post
    Ahhh

    6502 assembler
    Beans on toast for tea
    Jumpers for goalposts

    http://uk.youtube.com/watch?v=3NeRoSFZWbs
    I started out writing games on the ZX48 in the mid-80s in BASIC as a hobby. I used to dabble in Z80. I remember being amazed that you could draw in the Border on the Spectrum. Take up the whole screen instead of just the bit inside the border. Last game i played was in about 1990. Those two quid CodeMasters games. Some of them were great! Tape to Tape at my mates house. Get 10 on a C60 cassette! Yes, I did a lot of w*****g back then.

    Leave a comment:


  • bogeyman
    replied
    Originally posted by NickFitz View Post
    When I was writing games for a living we subcontracted some work to a bloke who claimed to be an ace C64 programmer.

    See if you can spot the main problem with this fine bit of code he came up with:

    Code:
    .add100points
       LDX #100
    .loop
       CLC
       LDA scorelo
       ADC #1
       STA scorelo
       LDA scorehi
       ADC #0
       STA scorehi
       DEX
       BNE loop
       RTS
    Ahhh

    6502 assembler
    Beans on toast for tea
    Jumpers for goalposts

    For the curious, this hotshot game dev adds 1 to 'scorelo' one hundred times, in a loop. Just to be fair, he adds zero to 'scorehi' while he's at it. Presumably he doesn't know that ADC (add with carry) will accept numbers greater than one, or that 'scorehi' won't feel neglected if you don't also give it some love by adding zero to it 100 times. Note how he carefully clears the carry flag (CLC) for every iteration of the loop.

    Presumably the task was to allow for scores >= 255 with the 'lo' and 'hi' bytes representing low and high order bytes of a 16-bit integer. As it stands you'd see your score drop back alarmingly just when you thought you were getting somewhere - like on the Weakest Link when they don't 'bank'.

    http://uk.youtube.com/watch?v=3NeRoSFZWbs
    Last edited by bogeyman; 29 September 2008, 22:42. Reason: what the code does

    Leave a comment:


  • aussielong
    replied
    Originally posted by BrilloPad View Post
    No comments?
    I'll bite. Doesn't it do a loop of 100 "+1"s just to add 100 to scorelo? Why not just add 100, instead of adding 1, 100 times? Aswell as adding 0 to a number, 100 times!

    Leave a comment:


  • NickFitz
    replied
    Originally posted by BrilloPad View Post
    No comments?
    It certainly left all of us speechless

    Leave a comment:


  • BrilloPad
    replied
    Originally posted by NickFitz View Post
    When I was writing games for a living we subcontracted some work to a bloke who claimed to be an ace C64 programmer.

    See if you can spot the main problem with this fine bit of code he came up with:

    Code:
    .add100points
       LDX #100
    .loop
       CLC
       LDA scorelo
       ADC #1
       STA scorelo
       LDA scorehi
       ADC #0
       STA scorehi
       DEX
       BNE loop
       RTS
    No comments?

    Leave a comment:


  • NickFitz
    replied
    Originally posted by bogeyman View Post
    Completely dissagree old dog.

    If anything, the 6502 was the first RISC chip. The Z80 series as an 8080 with a load of cobbled-on old tat.

    LDA
    LDX
    LDY

    Ahhh
    When I was writing games for a living we subcontracted some work to a bloke who claimed to be an ace C64 programmer.

    See if you can spot the main problem with this fine bit of code he came up with:

    Code:
    .add100points
       LDX #100
    .loop
       CLC
       LDA scorelo
       ADC #1
       STA scorelo
       LDA scorehi
       ADC #0
       STA scorehi
       DEX
       BNE loop
       RTS

    Leave a comment:


  • Bob Dalek
    replied
    Originally posted by bogeyman View Post
    Completely dissagree old dog.

    If anything, the 6502 was the first RISC chip. The Z80 series as an 8080 with a load of cobbled-on old tat.

    LDA
    LDX
    LDY

    Ahhh
    WHS... I think.

    Leave a comment:


  • Bob Dalek
    replied
    Originally posted by Ruprect View Post
    Surely Bob you're bordering on Libel!
    Essex, actually.

    Leave a comment:


  • bogeyman
    replied
    Originally posted by Churchill View Post
    The Z80A is a far superior processor to the 6502!
    Completely dissagree old dog.

    If anything, the 6502 was the first RISC chip. The Z80 series as an 8080 with a load of cobbled-on old tat.

    LDA
    LDX
    LDY

    Ahhh

    Leave a comment:


  • Ruprect
    replied
    Surely Bob you're bordering on Libel!

    Leave a comment:

Working...
X