Previous Thread
Next Thread
Print Thread
Page 11 of 11 1 2 9 10 11
Joined: Feb 2014
Posts: 681
Likes: 9
G
Senior Member
OP Offline
Senior Member
G
Joined: Feb 2014
Posts: 681
Likes: 9
I wanted to be able to scale the bitmap so I could save a scaled version. This would be useful to double the pixels vertically so 120x72 would be 120x144 which would look more "square".

So why not expose a copyrozbitmap function to lua so I could experiment/test with it?
Code
void mycopyroz(bitmap_rgb32& dest, bitmap_rgb32& src, int srcx, int srcy, int destx, int desty, int width, int height, double scalex, double scaley) {
	copyrozbitmap(dest, rectangle(destx,destx+width*scalex-1,desty,desty+height*scaley-1), src, 
	((srcx+0.01) * 1.0 - destx * (1.0/scalex) ) * 0x10000, 
	((srcy+0.01) * 1.0 - desty * (1.0/scaley) ) * 0x10000, 
	0x10000 * (1.0/scalex), 0, 0, 
	0x10000 * (1.0/scaley), false);
	}

and then I can do stuff like:

Code
lp0 = manager:machine().lp[1] 

lp0:clearpage(0,0xffffff)
lp0:clearpage(-1,0x808080)

function drawx(x1,y1,size) 
  local y2 = y1+size-1 local x2 = x1+size-1 
  for i=0,size-1 do 
    lp0:drawpixel(x1+i,y1) lp0:drawpixel(x1+i,y2) lp0:drawpixel(x1,y1+i) lp0:drawpixel(x2,y1+i) lp0:drawpixel(x1+i,y1+i) lp0:drawpixel(x2-i,y1+i) 
  end 
end

drawx(0,0,20)  

lp0:savepagescale(0,2.0,4.0)   -- save page 0 at magnification 2.0 horiz and 4.0 vertically

for i = 0,20 do lp0:mycopyroz(lp0.m_lp_bitmap,lp0.m_lp_bitmap,0,792,70+40*i,792,20,20,2,2) end

xpos = 0 
for i = 1,10 do 
  mag = i size = 20 * mag lp0:mycopyroz(lp0.m_lp_bitmap,lp0.m_lp_bitmap,0,792+0,xpos,792-100,size/mag,size/mag,mag,mag) 
  xpos = xpos + size 
end

lp0:setheadpos(0,20)

lp0:saveall()
[Linked Image from i.imgur.com]

Joined: Feb 2014
Posts: 681
Likes: 9
G
Senior Member
OP Offline
Senior Member
G
Joined: Feb 2014
Posts: 681
Likes: 9
[Linked Image from i.imgur.com]

Experimenting with making a half-inch green bar paper background.

or a non-0xffffff background:

[Linked Image from i.imgur.com]

Joined: Feb 2014
Posts: 681
Likes: 9
G
Senior Member
OP Offline
Senior Member
G
Joined: Feb 2014
Posts: 681
Likes: 9
And why not add the ability to draw lines into our bitmap too:


[Linked Image from i.imgur.com]

Use a drawline routine from the hp9845 driver and make some changes:

Code
//void hp9845ct_base_state::draw_line(unsigned x0 , unsigned y0 , unsigned x1 , unsigned y1)
void drawline(int x0 , int y0 , int x1 , int y1, u32 pixelval)
{
        int dx, dy, sx, sy, x, y, err, e2;

        // draw line, vector generator uses Bresenham's algorithm
        x = x0;
        y = y0;
        dx = abs((int) (x1 - x));
        sx = x < x1 ? 1 : -1;   // actually always 1 because of normalization
        dy = abs((int) (y1 - y));
        sy = y < y1 ? 1 : -1;
        err = (dx > dy ? dx : -dy) / 2;

        for(;;){
//                plot(x, y, BIT(m_gv_line_type_mask, 15));
//               update_line_pattern();

		if (!((x<0) || (x >= m_lp_bitmap->width()) || (y<0) || (y >= m_lp_bitmap->height()))) 
					m_lp_bitmap->pix32(y,x) = pixelval;

                if (x == x1 && y == y1) break;

                e2 = err;
                if (e2 > -dx) {
                        err -= dy;
                        x += sx;
                }
                if (e2 < dy) {
                        err += dx;
                        y += sy;
                }
        }
}



and make some spokes:

Code
function drawcirclespokes(cx,cy,size,step,color) 
for i=0,360,step do 
  manager:machine().lp[1]:drawline(math.floor(cx),math.floor(cy),math.floor(cx+size*math.cos(i/360*2*math.pi)),math.floor(cy+size*math.sin(i/360*2*math.pi)),color) 
  manager:machine().lp[1]:drawline(math.floor(cx+size*math.cos(i/360*2*math.pi)),math.floor(cy+size*math.sin(i/360*2*math.pi)),
math.floor(cx+size*math.cos((i+step)/360*2*math.pi)),math.floor(cy+size*math.sin((i+step)/360*2*math.pi)),color)
 end
end

drawcirclespokes(200,792,150,360/36,0)
drawcirclespokes(0,0,360,360/36,0)
drawcirclespokes(8.5*120,0,360,360/36,0)
drawcirclespokes(9.0*120,792,360,360/36,0)


Joined: Feb 2014
Posts: 681
Likes: 9
G
Senior Member
OP Offline
Senior Member
G
Joined: Feb 2014
Posts: 681
Likes: 9
Some more experiments:

I made an array of bitmap_rgb32 and a readpngtobitmap routine and exposed them to lua:
Code

	bitmap_rgb32 bitmaparray[10];
	bitmap_rgb32 * getbitmaparrayitem(int item) { return &(bitmaparray[item]); }
	
	void bitmapalloc(bitmap_rgb32& bitmap, int width, int height){ bitmap.allocate(width,height); }


int readpngtobitmap(bitmap_rgb32& bitmap, std::string filename){

         emu_file file("",OPEN_FLAG_READ);;
        osd_file::error const filerr = file.open(filename);
        if (filerr != osd_file::error::NONE)
                {printf("no file!\n"); return 0;}

        // read the PNG data
        png_info png;
        png_error const result = png.read_file(file);
        file.close();
        if (result != PNGERR_NONE)
        {
                osd_printf_error("%s: Error reading PNG file\n", filename);
                return 0;
        }
   bool hasalpha=false;
   png_error result2 = png.copy_to_bitmap( *((bitmap_argb32 * ) &bitmap), hasalpha);
   
      if (PNGERR_NONE != result2)
                {
                        osd_printf_error("%s: Error copying PNG bitmap to MAME bitmap\n", filename);
                        osd_printf_error("Error result = %d\n", result);
                        return false;
                }

printf("bitmap size %d %d\n",bitmap.width(),bitmap.height());
	return 1;
}

which allows me to load various bitmap fonts as pngs so I can use those fonts:

Opening ubuntu's character map on Noto Mono 22:
[Linked Image from i.imgur.com]

Taking a screencap and figuring out the grid size in Gimp:
[Linked Image from i.imgur.com]

and a test of what the font would look like (scaling the font to 66% to make it fit 80 columns wide):
[Linked Image from i.imgur.com]

Code
manager:machine().lp[1]:readpngtobitmap(manager:machine().lp[1]:getbitmaparrayitem(4),"grid.png")

function drawstringscaleoffset(x,y,str,bitmap,xsize,ysize,rowsize,spacing,scale,offsetx,offsety,offsetsizex,offsetsizey,linegap,rtmar)
xpos = x ypos = y
  for i=1,str:len() do c = str:byte(i) if c>=32 and c<=127 then cpos = c - 32 colpos = cpos % rowsize rowpos = math.floor(cpos/rowsize) lp0:mycopyroz(lp0.m_lp_bitmap, bitmap, math.floor(colpos*xsize+offsetx),math.floor(rowpos*ysize+offsety) , xpos,ypos+792, offsetsizex, offsetsizey, scale, scale)
xpos = xpos + spacing end if xpos > rtmar or c==10 then xpos = x ypos=ypos+offsetsizey+linegap end
end
end
drawstringscaleoffset(20,-792+100,zstring,lp0:getbitmaparrayitem(4),65.75,61,16,12,0.66,25,16,20,35,-14,120*8+20)

and an experiment with a spectrum zx 8x8 font (from DamienG's ZX Origins webpage):

(I couldn't figure out why the png wouldn't load and then I realized it was an 8-bit indexed png. After converting the file to rgb with gimp and exporting it worked fine.)

[Linked Image from i.imgur.com]

Joined: Feb 2014
Posts: 681
Likes: 9
G
Senior Member
OP Offline
Senior Member
G
Joined: Feb 2014
Posts: 681
Likes: 9
One of the things I would do back in the day was to turn off and on the printer to clear the internal buffer, especially on a runaway print job, so how to do it on the Ap2000?

You can reset the maincpu and that won't quite do it. You can also send an NMI interrupt, and that won't quite do it.

After some experimentation, it seems that you have to do both.

You have to reset the maincpu and then send an NMI interrupt a short while later (minimum 0.9 seconds later).

Code
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Reset Printer") PORT_CODE(KEYCODE_2_PAD) PORT_CHANGED_MEMBER(DEVICE_SELF, epson_lx810l_device, reset_printer, 0)

INPUT_CHANGED_MEMBER(epson_lx810l_device::reset_printer)
{
	if (newval)
	{
		m_maincpu->pulse_input_line(INPUT_LINE_RESET, attotime::zero);  // reset cpu
		m_e05a30->reset();  // this will generate an NMI interrupt when the e05a30 is ready (minimum 0.9 seconds after reset)
	}
}

and then it's not too hard to hook up the centronics init signal to a routine that will pulse the reset line and reset the e05a30 too.

I found a neat little DOS program that would allow init testing:
Parallel Port Debug Tool Version 2.0

[Linked Image from i.imgur.com]

[Linked Image from i.imgur.com]

Page 11 of 11 1 2 9 10 11

Link Copied to Clipboard
Who's Online Now
4 members (Revenant, will, AJR, 1 invisible), 23 guests, and 4 robots.
Key: Admin, Global Mod, Mod
ShoutChat
Comment Guidelines: Do post respectful and insightful comments. Don't flame, hate, spam.
Forum Statistics
Forums9
Topics8,993
Posts118,149
Members5,005
Most Online890
Jan 17th, 2020
Forum Host
These forums are hosted by www.retrogamesformac.com
Forum hosted by www.retrogamesformac.com