Previous Thread
Next Thread
Print Thread
Page 9 of 11 1 2 7 8 9 10 11
Joined: Oct 2014
Posts: 3
R
Member
Offline
Member
R
Joined: Oct 2014
Posts: 3
Originally Posted by R. Belmont
Reading this makes me realize how much a dot-matrix printer is like a write-only floppy drive, except it controls the exact media position instead of waiting for it to come around to the right spot.

Great idea for a hackerspace project: a dot-matrix printer that spins the paper and waits for the right spot to come around for each dot.

Joined: May 2009
Posts: 1,879
J
Very Senior Member
Offline
Very Senior Member
J
Joined: May 2009
Posts: 1,879
True, but you would need to ensure that your paper has an index hole.

Joined: Mar 2001
Posts: 16,613
R
Very Senior Member
Offline
Very Senior Member
R
Joined: Mar 2001
Posts: 16,613
Or write some kind of a sync mark and watch for it to come around.

Joined: Feb 2014
Posts: 504
G
Senior Member
OP Offline
Senior Member
G
Joined: Feb 2014
Posts: 504
I liked being able to call lua so much I made a class called luacall:

Code
/***************************************************************************
    luacall.h
    Utility class for calling lua
***************************************************************************/

#ifndef MAME_LUACALL_H
#define MAME_LUACALL_H

#pragma once

class lua_engine;

class luacall {
	public:
		static lua_engine *m_luaengine;
		static void        (lua_engine::* lualoadstringf)  (const char * astr);
		static int         (lua_engine::* luagetintvarf)   (const char * astr);
		static double      (lua_engine::* luagetdoublevarf)(const char * astr);
		static std::string (lua_engine::* luagetstringvarf)(const char * astr);

	static void lualoadstring(const char *astr) { 
			((*m_luaengine).*lualoadstringf)(astr); 
		}

	static int luagetintvar(const char *astr) {
			int retval =  ((*m_luaengine).*luagetintvarf)(astr); 
			return retval;
		}

	static double luagetdoublevar(const char *astr) {
			double retval =  ((*m_luaengine).*luagetdoublevarf)(astr); 
			return retval;
		}

	static std::string luagetstringvar(const char *astr) {
			std::string retval =  ((*m_luaengine).*luagetstringvarf)(astr); 
			return retval;
		}

}; // end class luacall  

#endif  // MAME_LUACALL_H

/***************************************************************************
    luacall.cpp
    Utility class for calling lua functions
***************************************************************************/

#include "emu.h"
#include "luacall.h"

lua_engine *luacall::m_luaengine;
void      (lua_engine::* luacall::lualoadstringf)  (const char * astr);
int         (lua_engine::* luacall::luagetintvarf)   (const char *astr);
double      (lua_engine::* luacall::luagetdoublevarf)(const char *astr);
std::string (lua_engine::* luacall::luagetstringvarf)(const char *astr);

luaengine.h:
Code
	int luagetintvar( const char *astr);
	double luagetdoublevar( const char *astr);
	std::string luagetstringvar( const char *astr);

and in luaengine.cpp:
Code
		luacall::m_luaengine = this; 
		luacall::lualoadstringf   = &lua_engine::load_string;
		luacall::luagetintvarf    = &lua_engine::luagetintvar;
		luacall::luagetdoublevarf = &lua_engine::luagetdoublevar;
		luacall::luagetstringvarf = &lua_engine::luagetstringvar;

	int         lua_engine::luagetintvar   ( const char *astr) { return sol()[astr]; };
	double      lua_engine::luagetdoublevar( const char *astr) { return sol()[astr]; };
	std::string lua_engine::luagetstringvar( const char *astr) { return sol()[astr]; };


so then I can do stuff like:

Code
// call lua with a string to execute:
	char buffer[128];
	snprintf(buffer,128,"if drawdot then drawdot( %f, %f ) end", xcoord, ycoord);
	luacall::lualoadstring(buffer);

// get the value from a double var:

printf("Get Double %f\n",luacall::luagetdoublevar("testdouble"));

//some indirection: get a double var from the name stored in the variable named by teststring2

printf("Testing luagetstring:   value for %s %f\n",
                luacall::luagetstringvar("teststring2").c_str(),
		luacall::luagetdoublevar(luacall::luagetstringvar(luacall::luagetstringvar("teststring2").c_str()).c_str()));

// get the value from a integer var:
printf("Get Int %d\n",luacall::luagetdoublevar("testint"));



If the variable isn't defined, it seems to just return 0, 0.0 or the empty string.

Code
Testing luagetstring:   value for  0.000000
Get Double 0.000000
Get Int 0
[MAME]> testdouble=5.29
[MAME]> testint=300
[MAME]> teststring2="orange"
[MAME]> orange="grape"
[MAME]> grape=777
[MAME]> 
Testing luagetstring:   value for orange 777.000000
Get Double 5.290000
Get Int 300



Joined: Feb 2014
Posts: 504
G
Senior Member
OP Offline
Senior Member
G
Joined: Feb 2014
Posts: 504
I think I may have solved the mystery of the missing bottom line. The font data is stored as 8 bits, with the bottom line saved as 3 bytes. These bytes go into a shift register when written to c001,c002 and c003 and they get shifted out at c000.

So now you can see the bottom of the character [:

[Linked Image from i.imgur.com]

so at 2708 DE gets loaded with C001 and C gets 2 so we transfer 3 bytes to c001,c002,c003 with the BLOCK instruction.

then at 2714 we read the value at C000 for our 9th pin, the other 8 bits coming from LDAX (HL+).

[Linked Image from i.imgur.com]


It seems to work for the self test, anyway.




Code

void e05a30_device::write(offs_t offset, uint8_t data)
{
	LOG("%s: e05a30_w([0xC0%02x]): %02x\n", machine().describe_context(), offset, data);

	switch (offset) {
	case 0x0:
	case 0x1:
	case 0x2:
	case 0x3:
		c000_shift_register &= ~(0xff << ((3-offset)*8));
		c000_shift_register |= (data << ((3-offset)*8));
		break;

...

uint8_t e05a30_device::read(offs_t offset)
{
	uint8_t result = 0;

	LOG("%s: e05a30_r([0xC0%02x]): ", machine().describe_context(), offset);

	switch (offset) {
	case 0x0: 
			c000_shift_register <<= 1;  // put shift before the capture
			result = (c000_shift_register & 0x1000000) ? 0x80 : 0x0; 
			break;

Joined: Feb 2014
Posts: 504
G
Senior Member
OP Offline
Senior Member
G
Joined: Feb 2014
Posts: 504
So if we can print 9 bits of the printhead, why not see if ESC ^ 9-pin graphics mode works:

[Linked Image from i.imgur.com]

According to the ESC P manual, the second byte's LSB is the 9th pin, but it's actually the MSB, just as in the printer internals.

Code

    1 GOTO 10
    5 X = PEEK( (12*16+1)*256 ) : P = 12*256*16+9*16 : FOR I=1 TO LEN(A$) : POKE P,ASC(MID$(A$,I,1)):NEXT:RETURN
   10 REM APPLE PARALLEL CARD, READ FROM C100 SETS UP STROBE, THEN POKE C090 WILL SEND CHARACTERS


     100 N = 120 * 3 : N1=((N/256)-INT(N/256))*256 :N2=INT(N/256) :? N,N1,N2:A$=CHR$(27)+"^"+CHR$(1)+CHR$(N1)+CHR$(N2) : GOSUB 5
     110 FOR J = 1 TO N/2 : A$=CHR$(1+4+(1+4)*16)+CHR$(128) : GOSUB 5 : A$=CHR$(2+8+(2+8)*16)+CHR$(128):GOSUB 5:NEXT:A$=CHR$(10):GOSUB 5




[Linked Image from i.imgur.com]

Although, come to think of it, this probably worked before the 9-pin fix since it's not going through the shift register 8-)

Joined: Mar 2001
Posts: 16,613
R
Very Senior Member
Offline
Very Senior Member
R
Joined: Mar 2001
Posts: 16,613
Can you submit a pull request for the shift register fix? That would be great smile

Joined: Feb 2014
Posts: 504
G
Senior Member
OP Offline
Senior Member
G
Joined: Feb 2014
Posts: 504
Sure, RB!

(if I can get my git straightened up again 8-)

I managed to get the font looking improved, but it still isn't quite right.

The ap2000 does the NLQ fonts by printing one sequence of 9 bits, feeding the paper by 1/216" then printing the next sequence of 9 bits.

It's kinda hacky yet, but I do like the little "circles" look on the i and the r and the 2.


This is at 240x144 dots:

[Linked Image from i.imgur.com]

Joined: Mar 2001
Posts: 16,613
R
Very Senior Member
Offline
Very Senior Member
R
Joined: Mar 2001
Posts: 16,613
Neat! I love those little circles too smile

Joined: Feb 2014
Posts: 504
G
Senior Member
OP Offline
Senior Member
G
Joined: Feb 2014
Posts: 504
Ok I made a PR:

ap2000 add shift register for c000 - fixes the missing 9th pin line #7366

I cloned a fresh repo so I wouldn't make a mess.

It's strange, testing it out but the keys stopped working, like holding keypad 7 (FF) when starting up to get it to go into self test mode. And holding down keypad 0 to toggle online doesn't work either.

Page 9 of 11 1 2 7 8 9 10 11

Link Copied to Clipboard
Who's Online Now
1 members (1 invisible), 36 guests, and 3 robots.
Key: Admin, Global Mod, Mod
ShoutChat
Comment Guidelines: Do post respectful and insightful comments. Don't flame, hate, spam.
Forum Statistics
Forums9
Topics8,836
Posts116,223
Members4,921
Most Online890
Jan 17th, 2020
Powered by UBB.threads™ PHP Forum Software 7.7.5