BCP: a BBC Micro printed circuit design program

bbc/electron apps, languages, utils, educational progs, demos + more
julie_m
Posts: 241
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: BCP: a BBC Micro printed circuit design program

Post by julie_m » Sat Nov 02, 2019 10:22 pm

BAD NEWS: The graphics library has overflowed the initial estimate of 2kB -- which is also the practical limit of the associated BASIC source code, if building on a Model B (for which there is still some hope).
GOOD NEWS: I can separate out all the maths stuff from the drawing stuff, and in so doing I'll be able to apply a trick I have spotted to condense down some similar code. This will give me a separate maths library to build, and another variable dump to import; but at least nothing in the maths library is likely to change for awhile now. I can even offload some code to there that I had in the database manager.

Also, my workspace registers are a bit of a mess, so I will rearrange them so all the co-ordinate pairs are together and all the base addresses are together.

So then, there is going to be the £64000 question: Will it ever build again?

cmorley
Posts: 1347
Joined: Sat Jul 30, 2016 8:11 pm
Location: Oxford
Contact:

Re: BCP: a BBC Micro printed circuit design program

Post by cmorley » Sun Nov 03, 2019 7:09 am

Are you already putting the code through a BASIC cruncher? JGH wrote (at least?) one (google mdfs crunch). There are plenty of tips for reducing BASIC code size too - have you been targetting this aggressively already? e.g. every new line costs a CR and two(!) bytes for line number IIRC so : is a clear winner. There are many other tips about whitespace and unnecessary ( etc.

I don't do this while I am developing though only as a pass at the end to optimise the BASIC because it obfuscates everything. I just develop on something with more memory (Master/B with shadow/B with OS RAM 8) ) then optimise & crunch for a B.

julie_m
Posts: 241
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: BCP: a BBC Micro printed circuit design program

Post by julie_m » Mon Nov 04, 2019 2:45 pm

The BASIC isn't the real limitation here; rather, it's the object code that's overgrown the (arbitrary) initial allotted size.

I'm going to separate out all the "mathsy" bits (which mostly are in the graphics library, because that was where I started writing; but there is some code in with the database management that's arguably more mathematics than database) into their own library.

This will mean less space for the test program; but that just means I will have to rewrite more of it from BASIC to assembler.

The code is up there so if there's something really obvious I could have done with to shrink it, I'm all ears .....

julie_m
Posts: 241
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: BCP: a BBC Micro printed circuit design program

Post by julie_m » Wed Nov 06, 2019 11:36 pm

julie_m wrote:
Sat Nov 02, 2019 10:22 pm
So then, there is going to be the £64000 question: Will it ever build again?
Answer: It builds, but I have introduced a bug into the rotation code while I was working on separating the graphics and maths libraries. Y co-ordinates are coming through wrong -- everything is squished onto the centre line running across the component.

Oh, well, at least I know where to look now .....

EDIT: Found it ..... What a tart! :oops:

EDIT 2: And it's fixed. Behaving exactly as it used to, only a bit more versatile, hopefully. Remember, kids: Unit testing is important .....

julie_m
Posts: 241
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: BCP: a BBC Micro printed circuit design program

Post by julie_m » Sat Nov 09, 2019 7:59 pm

It's now able to save the points along a route!
bcp_50_saving_routes.png
bcp_50_saving_routes.png (4.01 KiB) Viewed 2948 times
This is after making the connections shown on the screen.
bcp_50_restoring_routes.png
bcp_50_restoring_routes.png (4.9 KiB) Viewed 2948 times
And this is after changing screen MODE to prove there is no cheating, and retrieving (some of) the points stored earlier. (The beginning of the command is missing, unfortunately; I didn't make the text window big enough. Or I'll make ) Note we are using PLOT 5, as opposed to PLOT 14 and PLOT 6 when we were creating the routes.

I'll put the code so far up on my GitHub sometime soon.

julie_m
Posts: 241
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: BCP: a BBC Micro printed circuit design program

Post by julie_m » Sun Jan 26, 2020 9:38 pm

Alas, no new screen shots.

I've been working on a proper program to generate wiring lists, as opposed to relying on just a couple I had already generated out of an obsolete version of a test suite (!) It's now generating output, using all-new code, but it's not quite right if you let it copy just the footprints in the design from a master footprint file.

Actually, I think I know where to look for the problem! BRB.

EDIT: Aye. What a dizzy mare I am. [-X If you're going to advance a pointer, it helps to advance it by the right number of bytes what you've inserted.

Now I can revisit my report generator and end up with a program to decompose a wiring list file back to a textual representation. This will allow me to do a there-and-back test. I've also got to work on a footprint generator. I need more data for my own tests!

I've also got to chop out much redundant stuff from the BASIC "playable demo" (it's full of test code that doesn't get called up anymore; I'm confident enough that they work. But the atavisms remain until the dreaded No room error comes a-knocking .....)

Ah well, another day .....

EDIT 2: Forgot to say: Allowing a program to write to screen memory is a seriously useful debugging technique! In my case I was able to spot data being overwritten and just not filling up as far as expected. That, in turn, suggested a pointer not being advanced properly .....

julie_m
Posts: 241
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: BCP: a BBC Micro printed circuit design program

Post by julie_m » Wed Feb 19, 2020 11:35 pm

I have written some more machine code to replace parts of the BASIC test program. And I now have a clear roadmap ahead for the command interpreter.
bcp_parse_cmd.png
bcp_parse_cmd.png (4.58 KiB) Viewed 2533 times
Bumping into memory limitations, so going to have to split out the assembly language source from the BASIC program that calls the machine code it builds. I've an idea for a new host-side development script, so this gives me a chance to test it!

julie_m
Posts: 241
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: BCP: a BBC Micro printed circuit design program

Post by julie_m » Fri Feb 21, 2020 7:18 am

Oh, yeah ..... The number of variables exported from this last chunk of assembler, which I'm already calling the app code now, is tiny compared to what came out of the libraries! This feels good :)

julie_m
Posts: 241
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: BCP: a BBC Micro printed circuit design program

Post by julie_m » Sat Feb 22, 2020 12:30 am

Here is a disc image containing a demo of what has been achieved so far. You can draw everything in the design; play at routing; and test the "M" (move) command.

f7 and f8 -- load one of two slightly different designs (they're actually more different than they look ;) ) each containing R1, R2, R3, R4, C1, C2, C3, CN1, CN2 and Q1. All the resistors but R3 are surface mount.
GOTO 12000 -- draws all components
GOTO 14200 -- starts routing test (needs components on screen)
GOTO 11000 -- expects commands such as M R1 to move R1. (Everything will be treated as MOVE) Then you can position the part on screen with the usual direction keys ZX:/, RETURN to paste, 1234 select rotation, 56 select side, 7890 select step, SPACE show updated co-ordinates.
Try ?layers=247 to turn topside copper off in 2-colour modes, ?layers=255 to turn it on in 4-colour modes.

Now it needs a despatcher to invoke the appropriate subroutine for each command! Stay tuned .....
bcpdemo2.ssd
DFS disc image
(92.5 KiB) Downloaded 25 times
It will run on a model B, and probably even an Electron, in MODE 4 or MODE 5. It also runs in MODE 129 on a Master 128.

User avatar
tricky
Posts: 4774
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: BCP: a BBC Micro printed circuit design program

Post by tricky » Sat Feb 22, 2020 1:02 pm

Sounds like you are really enjoying this; quite inspirational :)

julie_m
Posts: 241
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: BCP: a BBC Micro printed circuit design program

Post by julie_m » Sun Feb 23, 2020 12:47 am

tricky wrote:
Sat Feb 22, 2020 1:02 pm
Sounds like you are really enjoying this; quite inspirational :)
Well, I wouldn't be doing this if I wasn't enjoying the living daylights out of it :D

Screenshots; probably not really of much interest to anyone except hardcore hackers, but you can see me calling the subroutines from BASIC that are going to handle stuff for the "viewport" command.
bcp_vpmanip1.png
bcp_vpmanip1.png (6.3 KiB) Viewed 2415 times
bcp_vpmanip2.png
bcp_vpmanip2.png (5.67 KiB) Viewed 2415 times
My command parser idea is definitely working as I would have wanted, and I should be able to reuse the command despatch logic -- based on a table of three-byte records; each consisting of a character code and the address to jump to, if it is matched -- to handle command modifiers as well.

Commands will consist of a letter followed by optional modifiers, optoinally followed by space-separated parameters. VL 200 will move the viewport left 200 thou, VU will move the viewport up half its height, there will be similar commands VD for viewport down and VR for viewport right. VS will show the current viewport co-ordinates, and VH will reset the viewport to its home position.

So a command line beginning with V will be despatched to a routine to handle all Viewport commands; that will first check for a parameter and if present, save it, or if absent, fill in default values (half the viewport dimensions as calculated); then look at the second letter and despatch, depending on it, to a routine that will perform the requested action.

I just get the feeling doing it like this is going to be more efficient than naïvely doing a whole series of CMP instructions, each followed by a BNE to jump past the code to the next one. (Which is exactly how I did the keystroke parsing elsewhere; but that also tests for ranges which do similar things, e.g. 1 2 3 4 select rotations, 5 6 select sides, 7 8 9 and 0 select movement steps.)

But that's all for tomorrow :) Well, later today .....

julie_m
Posts: 241
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: BCP: a BBC Micro printed circuit design program

Post by julie_m » Sun Feb 23, 2020 4:53 pm

*SIGH* Two steps forwards, one step back.

Command parsing and despatching works exactly as I had hoped with command modifiers, so I have my V command! I can alter the viewport to my heart's content, and display its co-ordinates. So far, all good.

Now my BASIC so far has just naïvely drawn all the components, irrespective whether or not they were in the viewport. This hasn't been an issue up to now because I've never moved it from its "home" position for longer than necessary to check it was being respected when converting co-ordinates from internal units (0.0254mm. = 1 thou.; though there are also values in the database which are in steps of 0.0508mm. and 0.127mm. They get multiplied up) to screen (logical) pixels. Obviously now I want to skip drawing parts that fall outside the viewport. I wrote some code to test whether or not a part's boundary was inside the viewport, and I thought I had tested it thoroughly, but now it does not seem to behave the way I thought it did.

Grr. Without a routine to redraw the screen, my test program is stuck in an "unplayable" state. I'm going to have to study the code carefully and see exactly what I'm doing wrong. Place your bets now, if you're playing along at home!

EDIT: I've bodged around it for now, with a partially-rewritten routine test_pivp subroutine that still makes calls to its old inner subroutine in the maths library, and it seems to work! So here is my latest "playable demo".
  • You can adjust the viewport with VL left, VR right, VU up, VD down (all of which will move by half the viewport size if no parameter is given), VH for home, VS or just V to show co-ordinates.
  • You can draw all components in the viewport with D.
  • You can move a component with M and its designator, e.g. M R2. A component will be automatically undrawn when it is selected to move.
  • The W (Wire) command is recognised, but it does nothing even if you specify a valid component and pin e.g. W R1 2.
Get it here and try it out:
bcpdemo3.ssd
(87.5 KiB) Downloaded 24 times
EDIT 2: I spoke too soon. You will need to use

Code: Select all

?&4703=&5A
to fix the "in viewport" test, which was refusing to draw components that were partially overhanging the edges of the viewport. I'll update my working copy of the Source Code so future versions will not require this patch.

julie_m
Posts: 241
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: BCP: a BBC Micro printed circuit design program

Post by julie_m » Fri Feb 28, 2020 11:28 pm

Now we have the beginnings in place for the Wire command! Given a part and pin, it begins searching through the wiring list for a suitable destination, i.e. any pin which is connected to the same circuit node. (And so far, it doesn't do anything more than output some details to the screen: the current component, pin number, layer, width and circuit node. For each pin searched, it also displays the result of the "in viewport" test and pin co-ordinates. And never again will I take PRINT for granted!) The command given was W C1 1 to begin wiring from C1 pin 1:
bcp_wire1.png
Oh, wow! She's got rid of that crappy transistor preamp thing!
bcp_wire1.png (3.68 KiB) Viewed 2316 times
Watch what happens when we try again, with the viewport moved 300 thou. to the right (VR 300):
bcp_wire2.png
That's going to need more parts to make it work.
bcp_wire2.png (3.65 KiB) Viewed 2316 times
This time, R1 1 is skipped over, because the centre of the pad lies outside the viewport (8 in the fit result means "left of the viewport"), and the next available pin is IC1 3. So, I know the "next pin" logic works correctly. (I've also proved that infinite loop situations can't happen: I'm keeping a track of scans through the parts list and exiting if we hit the end of the list twice in a row without a match.) Now I just have to finish converting the rest of the BASIC demo wiring code to assembly language, add backtracking and layer/width changes, and that'll be the W command pretty much sorted .....

Not posting a disc image, because this isn't really in a state you can do anything with; PM me if you are really desperate!

julie_m
Posts: 241
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: BCP: a BBC Micro printed circuit design program

Post by julie_m » Sat Feb 29, 2020 9:09 pm

Guess who just spent an hour chasing something that was her own fault all along ..... :oops: I had stored a copy of some co-ordinates in a part of the workspace I knew I was not writing to ..... we'll call it plotbuf ..... but something was overwriting it nonetheless ..... been poring over listings, and then it hit me.

My "display decimal number" subroutine stomps on plotbuf, as it calculates the digits in ascending place value order and so needs to store them somewhere ..... it can't start printing them until it's got the first digit, which comes out last ..... well, plotbuf is just for temporarily storing co-ordinates and isn't going to be needed after the drawing is done, is it? Unless for debugging purposes, you add in a bunch of calls to disp_dn_X .....

Anyway, it's an easy enough fix; plotbuf is big enough to store the reversed digits and the co-ordinates I need to store.

julie_m
Posts: 241
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: BCP: a BBC Micro printed circuit design program

Post by julie_m » Sun Mar 01, 2020 10:23 pm

And, as promised, a disc image for you to play with:
bcpdemo4.ssd
(35 KiB) Downloaded 25 times
This jumps straight into the command mode. There are two more designs saved, that can be loaded by pressing f7 or f8. GOTO 11010 can be used to resume execution after stopping with an error.

You can now use the W command to wire up connections (e.g. W R1 1 to wire from pin 1 of R1; it doesn't yet accept a destination in with the command), and the routing data will be stored in memory as you go (although the only thing you can do with this information so far is escape out of the program and examine it .....) You still can't backspace along a route yet -- that'll be the next addition -- nor can you change width or layers yet.

BUGS: The D command doesn't clear the full screen because of the window I have added. CTRL+P while waiting for a command to be entered will clear the graphics window. After loading a design, you need to GOTO 12000 to reset the parts count (the D command isn't doing that, either). There is too much extraneous output (but it's staying as long as I'm not sure exactly which bits are extraneous).

EDIT: Can't leave you without another piccy:
bcp_wire3.png
bcp_wire3.png (4.84 KiB) Viewed 2242 times
Yes, it's drawing those routes from memory where they were stored previously! Using BASIC, which is cheating, but it proves it works .....

Anyway, I'm calling it a night for now.

julie_m
Posts: 241
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: BCP: a BBC Micro printed circuit design program

Post by julie_m » Sun Mar 08, 2020 2:59 pm

Backspacing during wiring works now, eventually! I don't think it helped much that my cat was sick on my handwritten notes .....

The code is a mess, though, and there's still a bit that's not quite right and will break the next addition; so I'm going to give it a bit of a tidy before posting another disc image!

cmorley
Posts: 1347
Joined: Sat Jul 30, 2016 8:11 pm
Location: Oxford
Contact:

Re: BCP: a BBC Micro printed circuit design program

Post by cmorley » Sun Mar 08, 2020 3:10 pm

What are you editing the code on? I do my BASIC work on a PC with lots of comments... then send to a B for testing via the serial port. Last stage is to crunch it before release. Since the original is still on the PC in verbose form it makes editing & refactoring a breeze. :)

julie_m
Posts: 241
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: BCP: a BBC Micro printed circuit design program

Post by julie_m » Sun Mar 08, 2020 4:24 pm

I'm doing the "minor" editing in BeebEm but I also have some scripts I've written to add and remove line numbers, so I can do major editing on the host (laptop running Ubuntu) when it's worth the bother of transferring files across. (Maybe I need to write a script to detokenise BASIC on the host.....)

There is no crunching required, as it's just enough BASIC for the embedded assembler and a variable export dance. Anyway, my code is far too beautiful to spoil in such a fashion!

cmorley
Posts: 1347
Joined: Sat Jul 30, 2016 8:11 pm
Location: Oxford
Contact:

Re: BCP: a BBC Micro printed circuit design program

Post by cmorley » Sun Mar 08, 2020 6:15 pm

julie_m wrote:
Sun Mar 08, 2020 4:24 pm
There is no crunching required, as it's just enough BASIC for the embedded assembler and a variable export dance. Anyway, my code is far too beautiful to spoil in such a fashion!
Until you run out of memory ;)

julie_m
Posts: 241
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: BCP: a BBC Micro printed circuit design program

Post by julie_m » Sun Mar 08, 2020 7:10 pm

Well, I've already run out of memory several times; which is why the source code is split up into multiple chunks now!

And I need to export variables created during assembling from one program into the next and preserve the names, so crunching the program would just mess that process up .....

julie_m
Posts: 241
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: BCP: a BBC Micro printed circuit design program

Post by julie_m » Mon Mar 16, 2020 10:22 pm

Just rewritten a chunk of code, almost from scratch, because I wasn't happy with it. It's for drawing "wide" lines (either as two parallel lines in outline mode, or as rectangles otherwise). And I seem to have saved a fair amount of space; it's actually no slower to do it without pre-calculating the co-ordinates, as the old routine only ever used half its pre-calc'ed values anyway (but which half depended on the direction of the line .....)

Just got to slip it into the graphics library now! That's definitely the right place for it, since it deals specifically with drawing things on the screen that will never be needed on the photoplotter (pads are "flashed" in a single operation, and tracks are drawn with thickness already, depending on the aperture code or "D-code"); and I have a cunning plan to use that space for drawing things on the photoplotter that will never be needed on the screen (specifically, triangles; there's no equivalent of PLOT 85, X%, Y% in the command language, so the triangle will have to be drawn out of overlapped parallel lines. What I plan to do is pick a side of the triangle, and draw a series of lines parallel to it, between their intersections with the other two sides. That's just solving pairs of simultaneous equations, bread and butter stuff really. But I'm getting ahead of myself .....) Also, I feel I ought to give the workspace in &0A00-&0AFF a tidy-up when I next do anything with the maths library. It's become a mess, with all sorts of variables stuffed in willy-nilly that probably could be arranged in a more sensible order.
bcpdemo5.ssd
(137.5 KiB) Downloaded 26 times

julie_m
Posts: 241
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: BCP: a BBC Micro printed circuit design program

Post by julie_m » Sat Mar 21, 2020 8:50 pm

Very loud swear words. Not only has my latest disc image somehow become corrupt, but it must have already been corrupt before I uploaded that one the other night. More swear words. How did I manage that anyway? I have a vague memory of deleting some files and running *COMPACT ..... maybe that broke it? More swear words. Maybe I'll be able to recover something with a hex editor.

EDIT: Just been and taken a quick dump :D Everything seems to be there; there are just pages of zeros between chunks of files. If I can find all the bits of a file, the later the better -- I've been changing the filename as I saved subsequent versions, so the later files will be bound to appear later in the disc image -- then I might be able to stitch them back together and recover something.

EDIT 2: Yes! It worked! On the third attempt, I managed to poke the right addresses into the right places of my cobbled-together disk image to be able successfully to LOAD the program I managed to piece back together, without getting the dreaded Bad program. It didn't require anything beyond what I'd regard as standard bread-and-butter hacking techniques; but if anyone's interested, I can write up how I did it.

EDIT 3: Now rebuilt the recovered wide lines demo with version 4 of the maths library! Here's an image that ought to work this time:
bcpdemo6.ssd
(37.5 KiB) Downloaded 24 times

julie_m
Posts: 241
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: BCP: a BBC Micro printed circuit design program

Post by julie_m » Tue Mar 24, 2020 10:12 pm

And after what felt like a lot of mucking about, it builds once again! The graphics library now contains the code to draw lines with thickness and I have rebuilt the database and design app code against it.

Here's what it looks like on a Master 128 in MODE 129:
bcp_tracks_7.png
bcp_tracks_7.png (3.8 KiB) Viewed 1978 times
Still did this by calling the code directly for the time being, but as far as the incremental improvements to the program go this feels big. I've got to neaten up the way segments join on the diagonal; but first let's see how it handles width changes, and then we can try bringing vias into the mix!
Attachments
bcpdemo7.ssd
(177.5 KiB) Downloaded 21 times

julie_m
Posts: 241
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: BCP: a BBC Micro printed circuit design program

Post by julie_m » Mon Apr 27, 2020 7:54 pm

Now I've found a really weird bug .....

I replaced this:

Code: Select all

.scale_to_screen
JSRset_scale_maybe
LDX#0
.scale1
LDA relX,X
STA mulA,X
INX
CPX#2
BNE scale1
JSR mult_div_16
LDX#0
.scale2
LDA quot,X
STA scrX,X
LDA relY,X
STA mulA,X
INX
CPX#2
BNE scale2
JSR mult_div_16
LDX#0
.scale3
LDA quot,X
STA scrY,X
INX
CPX#2
BNE scale3
RTS
With this:

Code: Select all

.scale_to_screen
JSRset_scale_maybe
LDX#relX MOD256
LDY#mulA MOD256
JSRcopy_word
NOP:NOP:NOP:NOP:NOP:NOP
JSR mult_div_16
LDX#quot MOD256
LDY#scrX MOD256
JSRcopy_word
LDX#relY MOD256
LDY#mulA MOD256
JSRcopy_word
NOP:NOP:NOP:NOP:NOP
JSR mult_div_16
LDX#quot MOD256
LDY#scrY MOD256
JSRcopy_word
NOP:NOP:NOP:NOP:NOP:NOP
RTS
(the NOPs are there to keep all entry points at the same addresses and obviate the need to rebuild anything yet) and managed to break drawing rat nests and selecting the next pin when wiring. If I escape out of the program and *LOAD just the relevant portion from the original code over the top of the new subroutine, the correct behaviour is restored. If I escape again and *LOAD the equivalent bytes from the new code, it does not work. Further investigation reveals that the specific problem is in the copying of the scaled Y co-ordinate from quot, quot+1 to scrY, scrY+1. The old code ends with an RTS after a BNE did not branch, so both Z and C are set.

So I changed one of the NOP instructions in the last group to SEC, and this made the next-pin code behave correctly again.

I think this proves that the search subroutine used in drawing rat-nests and selecting the next connected pin during wiring has an unwitting dependency on the carry having previously been set, when the absolute co-ordinates of a pin were converted to screen co-ordinates. There will now follow a protracted session of staring at a screen, scribbling notes and swearing ......

User avatar
BigEd
Posts: 3522
Joined: Sun Jan 24, 2010 10:24 am
Location: West Country
Contact:

Re: BCP: a BBC Micro printed circuit design program

Post by BigEd » Mon Apr 27, 2020 9:05 pm

(Ouch, close escape there with the corrupt files...)

julie_m
Posts: 241
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: BCP: a BBC Micro printed circuit design program

Post by julie_m » Tue Apr 28, 2020 6:32 pm

Yeah, the corruption thing was scary, but not quite as full-on scary as it could have been. At least it was inserting blocks of zeros aligned with 256-byte boundaries, which are easy enough to spot and remove. I have actually had the same thing happen again, so I think I have an idea what must have gone wrong.

In other news, I think I have found my "carry-sensitivity" bug!

Code: Select all

.next_pin
JSRN_sn_resume
BCSnp_1
DECilb
BEQnp_err
LDA&78
JSRN_search_node
.np_1
RTS
.np_err
BRK
EQUB55
EQUS"No connected pin"
BRK
N_search_node and N_sn_resume are entry points into a temporary clone of a subroutine in the database library which searches for component pins connected to a particular node. (It's cloned here so we can insert commands for debugging purposes.) What this routine is supposed to do is, search through the wiring list (from the current point) for a pin connected to the selected circuit node. And it returns with C=1 in the event of a match, or C=0 if there was no match. If we have been right through the parts list twice without finding a connected pin, we use BRK to return to BASIC with an error message.

Now, looking at the code and my own notes, it seems that I was originally relying on a side effect of CMP (and CPX / CPY): if the value given in the instruction is equal to the value in the register, then C=1 (on the 6502, "compare" is basically "set the carry, subtract, don't store the actual difference anywhere but do set N, Z and C accordingly"). Later on, I must have twigged there was actually no good reason not to get the absolute and screen co-ordinates of the found pin straight away on a match; and my "get_pin" routine happens to finish with a co-ordinate conversion. Which, in its previous incarnation, used a loop which terminated on a match, and so exited with C=1.

I'm going to have to change a JMP to a JSR followed by a SEC and RTS to keep the SEC near to where it really needs to be; I could get it a byte shorter by putting the SEC in the get_pin subroutine, but I really don't fancy the thought of being the poor sod who, one day in the future, has to try to debug this without the Source Code!

julie_m
Posts: 241
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: BCP: a BBC Micro printed circuit design program

Post by julie_m » Sun Jun 07, 2020 7:18 pm

Sorry for the lack of updates recently (and so much for "I can work on BCP while I'm stuck indoors") -- I've been doing mostly boring stuff, like rearranging code, based on the realisation that what I wanted to add into the graphics library would take it beyond the available space. And going back to my earlier "graphics test suite" idea, because I needed to be able to call individual subroutines under finer-grained control.

Well, having sorted out the graphics library as I want it, the whole thing now builds without protesting about any missing variables.

But that's all I can say for it so far; I've introduced some more errors somewhere. Need to grab a printout of the code so far (I'll do it on the laser at work :D ) and my coloured pens, and go back to testing individual subroutines again to try to work out what's up. I changed some entry point names, the better to reflect what the subroutine actually does, and must have slipped up.

Also, since a lead on a potential real Model B went cold, I've had fewer qualms about developing on an emulated Master 128. I do still want to target the Model B, with a version that runs albeit in a lower-memory MODE and can support only less ambitious designs. I figure even if the assembler source only builds on a 128K machine, it's not so bad as long as the machine code and its BASIC wrapper fit into a 32K machine.

Not going to lie, I really like the 128 ..... Maybe a real one of them will turn up one day!

julie_m
Posts: 241
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: BCP: a BBC Micro printed circuit design program

Post by julie_m » Sat Jun 13, 2020 11:04 pm

Well, I think I have found most of what was up with it. And as usual, it was something I messed about with ..... Of course, I would not have called it "messing about with it" if it had worked, so that's pretty much a given anyway. There is a label redefinition left over from where I botched trying to move some code. I can't just warm-patch around it to get rotation working properly while moving components, either, as the error meant the rest of it wouldn't behave properly with a double-sided board anyway. I might be able to pad with NOPs and so keep all other entry points the same.

Now to divert from the interactive design side for awhile and do some work on the report generation -- i.e., drill and photoplot files. I even have an idea it might not be beyond the bounds of feasibility to create PostScript output suitable for laser printing ..... just needs the aperture definitions turning into PostScript procedure definitions, and then we either call a procedure to flash a pad or set a width and draw a line. But first, there's the small matter of drawing triangles and creating text on the photoplotter ..... and that was the original reason for the code rearrangement in the first place, to try to create a separation allowing overlaying code that only deals with the photoplotter, with code that only deals with the screen display.

I'm also quite proud that since starting out, my internal database format is still almost exactly as my first sketches on paper (just with progressively fewer blank bits, and one feature removed that I may yet reinstate, especially as I am going to have to rework the maths library anyway). Means I got the data structure right first time!

julie_m
Posts: 241
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: BCP: a BBC Micro printed circuit design program

Post by julie_m » Mon Jun 15, 2020 11:32 pm

It is now back to working well enough to drop a disc image:
bcpdemo8.ssd
(132.5 KiB) Downloaded 15 times
Currently working on photoplotting routines .....

julie_m
Posts: 241
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: BCP: a BBC Micro printed circuit design program

Post by julie_m » Mon Sep 14, 2020 1:43 am

I got stuck with the photoplotting stuff and ended up going on a wild tangent, rewriting the maths library (it now does multiplications in about half the time it used to, and divisions in something nearer a third than half the time it used to. Getting this to work required rearranging zero page locations, which then led to a tidy-up of main workspace locations .....) and experimentally porting it back to a new, improved target-side build system -- though it's still fully BeebAsm-compatible, just requiring the appropriate sections chopping out and pasting in.

And I have just managed to get the "state of play so far" to build again on the target!

No rest, though ..... Functionality to be added ..... Should still just about fit into a naked Model B, though I am probably going to end up running it on a real Master 128!

Post Reply

Return to “8-bit acorn software: other”