Recent Updates Toggle Comment Threads | Keyboard Shortcuts

  • Jay Versluis 9:01 am on July 25, 2014 Permalink | Reply
    Tags: , ,   

    Categories: Commodore ( 13 )

    How to merge BASIC programmes on your Commodore C64, C128 and Plus/4 

    Commodore LogoYou can merge / combine / concatenate BASIC programmes on a Commodore computer. It’s often useful to develop shorter chunks of code and put them together for a larger app.

    Sadly there’s no built-in command that lets you do this, even though the C128 user guide hints that the CONCAT command can do this (if you’ve ever tried you know that this is not the case and only works for sequential data files).

    With a few peeks and pokes we can accomplish what we need. Here’s how:

    • after loading the fist programme, we’ll set the start of BASIC to the end of programme 1
    • then we’ll load the second programme
    • and finally return the start of BASIC to the first one

    We’re left with both programmes in memory – without any changes in line numbers. Depending on how you write the code a quick RENUMBER command may be necessary here. Even though you can run a programme when the line numbers are out of sequence, GOSUB and GOTO routines may not work as expected.

    The commands are slightly different for each machine.

    On the C64

    The start of BASIC is stored in 43/44, and ends just before the variables begin – which is stored in 45/46. Load your first programme, then type this:

    n=(peek(45)+256*peek(46))-2
    poke 44,n/256
    poke 43,n-256*peek(46)
    

    Load the second part, then reset the BASIC pointers to where the first part resides:

    poke 43,1
    poke 44,8
    clr
    

    On the Plus/4

    The Plus/4 works almost identical to the C64 in regards to storing the BASIC pointers, however the start of BASIC is at a different address. Load your first programme, then type this (just like on the C64):

    n=(peek(45)+256*peek(46))-2
    poke 44,n/256
    poke 43,n-256*peek(46)
    

    Load the second part, then reset the BASIC pointers:

    poke 43,1
    poke 44,16
    clr
    

    On the C128

    The C128 stores variables in a different memory bank. Therefore it has a dedicated pointer to the end of BASIC which is missing on the other computers. The memory map is slightly different, and the start of BASIC is stored in 45/46. Load your first programme, then type this:

    n=peek(174)+256*peek(175)-2
    poke 46,n/256
    poke 45,n-256*peek(46)
    

    Load the second part, then reset the BASIC pointers:

    poke 45,1
    poke 46,28
    clr
    

    And there you have it! Run any of these routines right after a reset or restart.

    Thanks to Rick Kephart for this tip. You may also be interested in another (more complex) solution to this puzzle by Jim Butterfield in which he reads each byte and merges them back on disk.

     
  • Jay Versluis 9:28 am on July 21, 2014 Permalink | Reply  
    Categories: iOS, Podcast ( 218 )

    Creating In-App Purchases in iOS 7 

    In this 7-part series I’ll show you how to create an In-App Purchase in iOS 7 with Xcode 5.1. The course will run you through everything from setting up your product in iTunes Connect, creating a custom shop class for easy re-use, making “first contact” with the App Store and how to deal with its responses.

    These are Parts 1+2 which are free to watch. You can see the rest of the course here: http://pinkstone.co.uk/creating-an-in-app-purchase-in-ios-7-and-xcode-5-1/

     
  • Jay Versluis 9:20 pm on July 16, 2014 Permalink | Reply
    Tags:   

    Categories: Commodore ( 13 )

    How to listen to your Commodore Datasette 

    datasetteDid you know that there’s a way to “listen” to a Datasette Drive, even though it’s not meant to play back the latest top twenty mixtapes?

    I’ve recently acquired a Commodore Plus/4 with 1531 Datasette. I remember having one of those in the eighties (with an adaptor to connect it to my C64 back then).

    The datasette is misbehaving, allegedly saving programmes but never loading them back in. Power is working fine, but as I no longer have a “cassette player” as such, I have no idea if it’s actually recording anything on the tape, or hearing what’s on it.

    I needed a way to playback the tape when I found this super short and very useful machine code snippet:

    0600 LDA $01 
    0602 ADC #$38 
    0604 STA $FF11 
    0607 STA $FF19 
    060A JMP $0600 
    

    When started with SYS 1536 the outer border of the Plus/4 will change according to what’s coming from the tape when you press play, and audio is quasi-modulated to the speaker output. It sounds rather distorted, but nevertheless you can hear what’s on the tape!

    To enter the programme, first type MONITOR which will take your out of BASIC and into the machine language monitor. Then type A 0600 followed by the first command (LDA $01). Now TEDMON will give you the next hex address, so just type the next command.

    When you’re done hit return, then type X (and return) to exit to BASIC. Here you can start the programme with SYS 1536, then PRESS PLAY ON TAPE. Enjoy!

    Note that this will not work on the C64, but you can hunt around for several “tape alignment” programmes which will work with similar principles – but I couldn’t find one for the Plus/4.

    Thanks for Marton for the code:

     
  • Jay Versluis 8:09 pm on July 14, 2014 Permalink | Reply  
    Categories: Commodore ( 13 )

    How to use ZoomFloppy 

    Commodore LogoZoomFloppy is an ingenious contraption by Nate Lawson which lets you connect real Commodore disk drives via USB to modern computers. It allows you to read and write old floppy disks from drives like the 1541, 1571, 1581 and several others.

    ZoomFloppy itself is a board with a USB connector (which also acts as the link to the modern machine), and a Commodore serial type connector (the standard cable used to connect a 1541 to a C64 for example). An optional parallel cable can also be attached which allows to transfer data faster and from copy protected disks. Other ports are also available but their use is probably only known to the inventor himself.

    ZoomFloppy

    Using ZoomFloppy is kind of half documented, the other half has to be guessed – perhaps my notes on how I got this working may help others.

    The manual explains that the software to talk to ZoomFloppy can be obtained on the following link, together with a copy of the manual:

    The page contains links to an installer for Windows and Mac, as well as source files for Linux which have to be compiled from source (which did not work on CentOS). The Windows installer is very straightforward and installs the OpenCBM tools in c:/opencbm.

    A driver needs to be installed manually (i.e. plugin in ZoomFloppy, wait for Windows to complain, then navigate to the OpenCBM directory and let it search there for the driver). Once complete ZoomFloppy can be operated via the OpenCBM command line tools without further need to install anything:

    CBMXfer GUI (Windows)

    Those of us more comfortable (and spoilt by) graphic user interfaces will be pleased to hear that several GUIs have been written to take advantage of OpenCBM. CBMXfer by Steven Gray is such an endeavour. It’s only available on Windows and makes reading from and writing to a Commodore disk drive as easy as using the Windows Explorer.

    Once downloaded and extracted, copy all files into the OpenCBM directory from which you can run the app by the same title. It is important for CBMXfer to live in the same directory as OpenCBM as it will execute those very files.

    One thing no piece of documentation mentions is that to open disk images (d64 / d71 / d81 etc) you need to add another file to this directory which comes with neither OpenCBM nor CBMXfer. The file is called c1541 and is part of the VICE Emulator:

    This tool can read disk images and is necessary to display a directory contained in such an image. You can find this file in the tools directory in VICE.

    CBMXfer

    Using CBMXfer

    CBMXfer allows you to copy single PRG files back and forth from your computer to a floppy, as well as read/write an entire disk image.

    For single files, simply select it on the left (your PC), then click the arrow pointing right (your Commodore floppy disk drive) and the file will be written. Proceed from right to left to copy a file from disk to your hard drive. You can of course select multiple files too.

    To copy an entire disk image to hard disk, do not select a file (or use the unselect option), then click the green arrow going right. It will prompt you to type a name for your image. Likewise, to copy a disk image back to floppy, select the image, then click the left arrow.

    Note that writing to floppy disks requires a formatted disk (and enough space in the case of single files).

     
  • Jay Versluis 8:51 am on July 14, 2014 Permalink | Reply  
    Categories: iOS, Podcast ( 218 )

    How to use a Popover on iPad 

    In this series I’ll show you how to create Popovers on iPad. They’re fairly easy to create once you get the hang of the inner workings of the UIPopoverController.

    I’ll show you how to create basic Popover in code and in your Storyboard, and we’ll discuss how you can retrieve data from a Popover when it’s dismissed. We’ll do this with a simple UIDatePicker. In the last video I’ll demonstrate how you can pick images from the camera roll using the UImagePickerController with a Popover – which is how you’re meant to do it on iPad.

    The series contains three videos in total. The first one is “free to air”, and the other two are for members only.

    You can watch the whole course here: http://pinkstone.co.uk/how-to-use-popovers-on-ipad/

     
  • Jay Versluis 1:33 pm on July 8, 2014 Permalink | Reply
    Tags: ,   

    Categories: Commodore ( 13 )

    How to load and save binary data on the C128 and Plus/4 

    Commodore LogoThanks to BASIC 7.0′s powerful commands we can load and save arbitrary sections of memory to disk using BLOAD and BSAVE.

    This was useful for dealing with machine code as well as raw image data. Both commands work on the C128 and Plus/4, but sadly the C64 was lacking in this area.

    BLOAD and BSAVE work much like DLOAD and DSAVE with the addition that you can specify a section of memory – like this:

    // save contents of the 40 column display
    BSAVE "FILENAME", P1024 TO P2023
    
    // save the contents of hi-res graphics and colour separately
    BSAVE "IMAGE", P8192 TO P16181
    BSAVE "COLOURS", P7168 TO P8167
    
    // save graphics and colour information together
    BSAVE "FULL IMAGE", P7168 TO P16181
    

    BLOAD doesn’t need additional parameters and will load a file back into memory where it originally resided – just like the standard LOAD “FILE”,8,1 (with the 1 at the end). You can however provide the starting memory and make the file load somewhere else instead:

    // load file to a different place in memory
    BLOAD "FILENAME", P10000
    
     
  • Jay Versluis 6:18 am on July 7, 2014 Permalink | Reply
    Tags: iPad, UIStoryboard,   

    Categories: iOS, Podcast ( 218 )

    How to change a UIStoryboard from iPhone to iPad in Xcode 5 

    In this screencast I’ll show you how to make an iPhone storyboard display as an iPad storyboard in Xcode 5.1′s Interface Builder. Under the hood a UIStoryboard is just an XML file, and with a small tweak we can make Xcode display it like an iPad or an iPhone. This is a good strategy if you’d like to use your iPhone storyboard as a starting point for an iPad version.

    You can read my full article on my iOS Dev Diary:

     
  • Jay Versluis 8:29 pm on July 6, 2014 Permalink | Reply
    Tags: , ,   

    Categories: Commodore ( 13 )

    How to set the time on your Commodore C64 / C128 

    Commodore LogoDid you know that the Commodore computers had a built-in clock? It wasn’t an exact science, and it didn’t show the date, but it was able to display a 24hr clock.

    It did this by counting how many seconds your machine was switched on, accessible in two variables TI and TI$ (short for TIME).

    TI$ is a string value in the format HHMMss, counting seconds. 112347 would mean 11:23am and 47 seconds. TI$ will be 000000 when you switch on the system. You can set it just like any other variable to set the time:

    TI$ = "094500"
    

    TI counts the number of 60th seconds since the system was switched on (don’t ask):

    print int(ti/60);" seconds since startup"
    

    Both values reset when you reset the system. Like all internal computer clocks it is relatively accurate, but does drift a second or two per day (we don’t notice this on modern systems because those talk to an NTP server once every day and sync themselves).

    TI and TI$ are present on the C64, C128, Plus/4 and many other Commodore variants.

     
  • Jay Versluis 1:15 pm on July 3, 2014 Permalink | Reply  
    Categories: MySQL ( 15 )

    How to find and replace in MySQL 

    Sometimes you need to change some text in a MySQL table. For example, imagine you want to correct a spelling mistake or a reference in all your WordPress posts without having to change them one by one.

    Here’s how to do it with a raw SQL command. This works only on a single table – repeat this for each table:

    update `wp_posts`
    set `post_content` = replace(post_content, 'Old Text', 'New Text')
    

    Note the use of standard ticks and back ticks here. First we’ll select the table in question (in this case wp_posts), then we’ll issue the find and replace query by selecting the column in the table (post_content), followed by the replace command.

    As soon as MySQL comes back all references will have changed from “Old Text” to “New Text”.

    Careful here: there is no undo function! Once executed, all changes are live instantly. Make a backup copy of your database before you do anything!

     
  • Jay Versluis 1:05 pm on July 3, 2014 Permalink | Reply  
    Categories: WordPress ( 82 )

    How to avoid 500 Internal Server Errors when using the WordPress Importer 

    wordpress-iconI’ve used the WordPress Importer on many occasions – most of which gave me more grief than results. Usually I end up with a white screen telling me that there was an “Internal Server Error”. It basically means that something went wrong, but nobody knows what it was – and there is no way to find out.

    While entertaining ideas of finding another hobby, I searched the web one last time to sift through the hundreds of posts by other users sharing the same woes – until I came across this forum post by Anon who had the same problem:

    Anon did not give up so easily and found a solution which WORKS GREAT – even though it doesn’t make sense, or is in any way documented:

    Rather than simply importing the XML file you receive from Tools – Export, turn this file into a GZIP file, and then import it.

    I have no idea why this works, but I’ve just tried it with WordPress 3.9.1 and it works like a charm. On a Mac, simply

    • open Terminal
    • type “gzip ” (with a space)
    • then drag the file in question into the Terminal session
    • this will paste the full path of that file

    Hit return and you have a .gz file. The original file is deleted automatically.

    You can also do this from the command line like this:

    gzip yourfile.xml
    

    Anon suggests that if you’re a Windows user you can use 7zip to create a .gz file.

     
c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
shift + esc
cancel